babalae/better-genshin-impact · error · ArgumentNullException

自动地脉花任务参数不能为空

Error message

自动地脉花任务参数不能为空

What it means

ArgumentNullException thrown by RunAutoLeyLineOutcropTask at line 414 when the AutoLeyLineOutcropParam argument is null. This task automates ley line outcrops and needs the param for its configuration; a null param is rejected before constructing the task.

Source

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

        var combatScript = CombatScriptParser.ParseContext(script, validate: false, defaultAvatarName: avatarName);
        if (combatScript.CombatCommands.Count == 0) return;

        _logger.LogInformation("执行 {Text}", "简易策略脚本");

        await CombatScriptExecutor.ExecuteAsync(combatScript, cancellationToken, _logger);
    }
    
    /// <summary>  
    /// 运行自动地脉花任务
    /// </summary>  
    /// <param name="param">自动地脉花任务参数</param>  
    /// <param name="customCt">自定义取消令牌</param>  
    /// <returns></returns>  
    public async Task RunAutoLeyLineOutcropTask(AutoLeyLineOutcropParam param, CancellationToken? customCt = null)  
    {  
        if (param == null)  
        {  
            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), "自动幽境危战任务参数不能为空");

View on GitHub (pinned to a7cb36712d)

Solutions

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

Example fix

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

// after (JS)
const llParam = new AutoLeyLineOutcropParam(/* settings */);
dispatcher.RunAutoLeyLineOutcropTask(llParam);
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

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

Prevention

When it happens

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

Common situations: Author forgot to construct AutoLeyLineOutcropParam. 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/2d1ff086f97fec70. Report an issue: GitHub.