{"record":{"id":"2f5123472ee43d4f","repo":"babalae/better-genshin-impact","slug":"0","errorCode":null,"errorMessage":"角色死亡后重试次数不能小于 0","messagePattern":"角色死亡后重试次数不能小于 0","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"warning","filePath":"BetterGenshinImpact/GameTask/AutoBoss/AutoBossTask.cs","lineNumber":1000,"sourceCode":"    /// 校验自动首领讨伐启动所需的 Boss、战斗策略、讨伐次数、补充树脂开关、重试次数和路线文件。\n    /// </summary>\n    /// <exception cref=\"Exception\">配置缺失、Boss 不支持、策略不存在或重试次数非法时抛出。</exception>\n    /// <exception cref=\"FileNotFoundException\">必需路线文件不存在时抛出。</exception>\n    private void Validate()\n    {\n        if (string.IsNullOrWhiteSpace(_taskParam.BossName))\n        {\n            throw new Exception(\"请选择需要讨伐的首领\");\n        }\n\n        if (!AutoBossData.IsSupportedBoss(_taskParam.BossName))\n        {\n            throw new Exception($\"暂不支持首领：{_taskParam.BossName}\");\n        }\n\n        if (_taskParam.ReviveRetryCount < 0)\n        {\n            throw new Exception(\"角色死亡后重试次数不能小于 0\");\n        }\n\n        if (_taskParam.SpecifyRunCount && _taskParam.RunCount < 1)\n        {\n            throw new Exception(\"指定讨伐次数必须大于 0\");\n        }\n\n        if (!_taskParam.SpecifyRunCount && (_taskParam.UseTransientResin || _taskParam.UseFragileResin))\n        {\n            throw new Exception(\"只有指定讨伐次数模式才能开启须臾树脂或脆弱树脂补充\");\n        }\n\n        if (string.IsNullOrWhiteSpace(_taskParam.CombatStrategyPath))\n        {\n            _taskParam.SetCombatStrategyPath(_taskParam.StrategyName);\n        }\n\n        if (!File.Exists(_taskParam.CombatStrategyPath) && !Directory.Exists(_taskParam.CombatStrategyPath))","sourceCodeStart":982,"sourceCodeEnd":1018,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/AutoBoss/AutoBossTask.cs#L982-L1018","documentation":"Validate 校验 ReviveRetryCount（角色死亡后重试次数）不能为负，< 0 即抛 Exception。这是数值合法性校验，防止负重试导致循环逻辑异常。","triggerScenarios":"用户在界面/配置文件将 ReviveRetryCount 设为负数；配置序列化或迁移产生负值。","commonSituations":"手动编辑配置；UI 数值控件允许负输入；旧配置字段含义变更。","solutions":["将 ReviveRetryCount 设为 0 或正整数（0 表示不重试）。","在 UI 用数值控件限定最小值 0。","反序列化后 clamp 到非负。"],"exampleFix":"// before\nif (_taskParam.ReviveRetryCount < 0)\n{\n    throw new Exception(\"角色死亡后重试次数不能小于 0\");\n}\n\n// after\n_taskParam.ReviveRetryCount = Math.Max(0, _taskParam.ReviveRetryCount);","handlingStrategy":"validation","validationCode":"_taskParam.ReviveRetryCount = Math.Max(0, _taskParam.ReviveRetryCount);\n// UI 数值控件 Minimum=0","typeGuard":null,"tryCatchPattern":null,"preventionTips":["UI 数值控件限定最小值 0。","反序列化后 clamp 非负。"],"tags":["validation","config","genshin","autoboss"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}