babalae/better-genshin-impact · error · ArgumentNullException
秘境任务参数不能为空
Error message
秘境任务参数不能为空
What it means
ArgumentNullException thrown by RunAutoDomainTask at line 336 when the AutoDomainParam argument is null. This overload takes a fully-formed param (unlike RunTask which builds params internally), so a null param has no domain/fight strategy/settings to run with.
Source
Thrown at BetterGenshinImpact/Core/Script/Dependence/Dispatcher.cs:336
}
public CancellationToken GetLinkedCancellationToken()
{
return GetLinkedCancellationTokenSource().Token;
}
/// <summary>
/// 运行自动秘境任务
/// </summary>
/// <param name="param">秘境任务参数</param>
/// <param name="customCt">自定义取消令牌</param>
/// <returns></returns>
public async Task<Dictionary<string, int>> RunAutoDomainTask(AutoDomainParam param, CancellationToken? customCt = null)
{
if (param == null)
{
throw new ArgumentNullException(nameof(param), "秘境任务参数不能为空");
}
CancellationToken cancellationToken = customCt ?? CancellationContext.Instance.Cts.Token;
return await new AutoDomainTask(param).Start(cancellationToken);
}
/// <summary>
/// 运行自动首领讨伐任务
/// </summary>
/// <param name="param">自动首领讨伐任务参数</param>
/// <param name="customCt">自定义取消令牌</param>
/// <returns></returns>
public async Task<Dictionary<string, int>> RunAutoBossTask(AutoBossParam param, CancellationToken? customCt = null)
{
if (param == null)
{
throw new ArgumentNullException(nameof(param), "自动首领讨伐任务参数不能为空");
}View on GitHub (pinned to a7cb36712d)
Solutions
- Construct AutoDomainParam with the required domain/strategy settings before calling.
- Null-check in JS before invoking.
- If settings come from the UI, fetch them first rather than passing null.
Example fix
// before (JS)
dispatcher.RunAutoDomainTask(param); // param is null -> throws
// after (JS)
if (!param) { throw new Error('AutoDomainParam is required'); }
dispatcher.RunAutoDomainTask(param); Defensive patterns
Strategy: validation
Validate before calling
// JS side
if (!param) throw new Error('AutoDomainParam is required');
dispatcher.RunAutoDomainTask(param); Type guard
// JS
function isAutoDomainParam(v) { return v != null && typeof v === 'object'; } Prevention
- Construct AutoDomainParam before calling RunAutoDomainTask.
- Null-check params in JS wrappers.
- Fetch UI settings first rather than passing null.
When it happens
Trigger: JS calls `dispatcher.RunAutoDomainTask(null)`. A param-builder function returned undefined and was passed through.
Common situations: Author forgot to construct AutoDomainParam. Conditional construction left the variable null.
Related errors
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/138201a832df161a.
Report an issue: GitHub.