babalae/better-genshin-impact · error · ArgumentNullException

自动幽境危战任务参数不能为空

Error message

自动幽境危战任务参数不能为空

What it means

ArgumentNullException thrown by RunAutoStygianOnslaughtTask at line 432 when the AutoStygianOnslaughtParam argument is null. This task automates Stygian Onslaught (幽境危战) encounters and requires the param for encounter/strategy settings.

Source

Thrown at BetterGenshinImpact/Core/Script/Dependence/Dispatcher.cs:432

            throw new ArgumentNullException(nameof(param), "自动地脉花任务参数不能为空");  
        }  
  
        CancellationToken cancellationToken = customCt ?? CancellationContext.Instance.Cts.Token;  
        await new AutoLeyLineOutcropTask(param).Start(cancellationToken);  
    }


    /// <summary>  
    /// 运行自动幽境危战任务
    /// </summary>  
    /// <param name="param">自动幽境危战任务参数</param>  
    /// <param name="customCt">自定义取消令牌</param>  
    /// <returns></returns>  
    public async Task RunAutoStygianOnslaughtTask(AutoStygianOnslaughtParam param, CancellationToken? customCt = null)
    {
        if (param == null)
        {
            throw new ArgumentNullException(nameof(param), "自动幽境危战任务参数不能为空");
        }

        CancellationToken cancellationToken = customCt ?? CancellationContext.Instance.Cts.Token;
        await new AutoStygianOnslaughtTask(param).Start(cancellationToken);
    }
    
    /// <summary>
    /// 运行背包物品计数任务。
    /// </summary>
    /// <param name="param">背包物品计数参数。</param>
    /// <param name="customCt">自定义取消令牌。</param>
    /// <returns>单物品返回数量;多物品返回名称到数量的脚本对象。</returns>
    public async Task<object?> RunCountInventoryItemTask(CountInventoryItemParam param, CancellationToken? customCt = null)
    {
        if (param == null)
        {
            throw new ArgumentNullException(nameof(param), "背包物品计数参数不能为空");
        }

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Construct AutoStygianOnslaughtParam with the required settings before calling.
  2. Null-check in JS before invoking.

Example fix

// before (JS)
dispatcher.RunAutoStygianOnslaughtTask(param); // null -> throws

// after (JS)
const sParam = new AutoStygianOnslaughtParam(/* settings */);
dispatcher.RunAutoStygianOnslaughtTask(sParam);
Defensive patterns

Strategy: validation

Validate before calling

// JS side
if (!param) throw new Error('AutoStygianOnslaughtParam is required');
dispatcher.RunAutoStygianOnslaughtTask(param);

Type guard

// JS
function isAutoStygianParam(v) { return v != null && typeof v === 'object'; }

Prevention

When it happens

Trigger: JS calls `dispatcher.RunAutoStygianOnslaughtTask(null)` or passes an undefined variable.

Common situations: Author forgot to construct AutoStygianOnslaughtParam. Param built conditionally and the branch did not run.

Related errors


AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13). Data as JSON: /api/errors/7f94658af155340d. Report an issue: GitHub.