{"record":{"id":"6f6c9ba4821370b1","repo":"babalae/better-genshin-impact","slug":"error-6f6c9b","errorCode":null,"errorMessage":"策略字符串不能为空","messagePattern":"策略字符串不能为空","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/Core/Script/Dependence/Dispatcher.cs","lineNumber":390,"sourceCode":"  \n        CancellationToken cancellationToken = customCt ?? CancellationContext.Instance.Cts.Token;  \n        var factory = GameTask.AutoFight.Factory.CombatTaskFactoryProvider.GetFactory(param.CombatStrategyPath);\n        var fightTask = factory.CreateTask(param);\n        await fightTask.Start(cancellationToken);  \n    }\n    \n    /// <summary>\n    /// 运行简易战斗策略脚本。\n    /// 使用策略语言直接控制角色执行动作（如 e、q、attack 等），适合快速操作。\n    /// </summary>\n    /// <param name=\"script\">策略字符串，支持逗号/换行/分号分隔指令，可选角色名前缀</param>\n    /// <param name=\"avatarName\">指定操作的角色名（可选，不指定则操作当前角色）</param>\n    /// <param name=\"customCt\">自定义取消令牌</param>\n    public async Task RunCombatScript(string script, string? avatarName = null, CancellationToken? customCt = null)\n    {\n        if (string.IsNullOrWhiteSpace(script))\n        {\n            throw new ArgumentException(\"策略字符串不能为空\", nameof(script));\n        }\n\n        CancellationToken cancellationToken = customCt ?? CancellationContext.Instance.Cts.Token;\n\n        // 1. 解析策略字符串（ParseContext 已处理全角符号、注释、分号/逗号分隔）\n        var combatScript = CombatScriptParser.ParseContext(script, validate: false, defaultAvatarName: avatarName);\n        if (combatScript.CombatCommands.Count == 0) return;\n\n        _logger.LogInformation(\"执行 {Text}\", \"简易策略脚本\");\n\n        await CombatScriptExecutor.ExecuteAsync(combatScript, cancellationToken, _logger);\n    }\n    \n    /// <summary>  \n    /// 运行自动地脉花任务\n    /// </summary>  \n    /// <param name=\"param\">自动地脉花任务参数</param>  \n    /// <param name=\"customCt\">自定义取消令牌</param>  ","sourceCodeStart":372,"sourceCodeEnd":408,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/Core/Script/Dependence/Dispatcher.cs#L372-L408","documentation":"ArgumentException thrown by RunCombatScript at line 390 when the `script` string is null, empty, or whitespace. The combat script is a DSL parsed by CombatScriptParser.ParseContext (e.g. 'e,q,attack'); an empty script has nothing to execute and the parser would error, so the guard rejects it early. Note this is ArgumentException, not ArgumentNullException, because it uses IsNullOrWhiteSpace.","triggerScenarios":"JS calls `dispatcher.RunCombatScript('')`, `RunCombatScript(null)`, or `RunCombatScript('   ')`. A script variable loaded from an empty file or unset config.","commonSituations":"Author left the script string empty as a placeholder. A file read returned empty. Whitespace-only content from a template.","solutions":["Pass a non-empty combat script string with at least one command (e.g. 'e,q,attack').","Validate the string is non-whitespace in JS before calling.","If the script is optional, skip the call entirely rather than passing empty."],"exampleFix":"// before (JS)\ndispatcher.RunCombatScript(script); // script is '' -> throws\n\n// after (JS)\nif (script && script.trim()) {\n  dispatcher.RunCombatScript(script);\n}","handlingStrategy":"validation","validationCode":"// JS side\nif (script == null || String(script).trim() === '') throw new Error('combat script string is required');\ndispatcher.RunCombatScript(script);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass a non-empty combat script with at least one command.","Skip the call entirely for optional/empty scripts rather than passing empty.","Validate loaded script files are non-empty before invoking."],"tags":["script","argument","combat-script","validation"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}