{"record":{"id":"5121ffca4968fb48","repo":"babalae/better-genshin-impact","slug":"currentcategory","errorCode":null,"errorMessage":"无法读取分类 {_currentCategory}。","messagePattern":"无法读取分类 (.+?)。","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/CharacterDevelopment/CharacterDevelopmentTask.cs","lineNumber":761,"sourceCode":"    {\n        PrepareCharacter(_characterIndex + 1);\n        _workflowState = CharacterDevelopmentState.OpenCharacterList;\n        return Task.FromResult(StateHandlerResult.Success);\n    }\n\n    [StateHandler(CharacterDevelopmentState.ReadCategory, RetryTimeout = 12000, RetryInterval = 300, TransitionTimeout = 3000)]\n    private async Task<StateHandlerResult> HandleReadCategory(BvPage page)\n    {\n        switch (_currentCategory)\n        {\n            case CharacterDevelopmentCategory.Attribute:\n                await ReadAttribute();\n                break;\n            case CharacterDevelopmentCategory.Weapon:\n                await ReadWeapon();\n                break;\n            default:\n                throw new InvalidOperationException($\"无法读取分类 {_currentCategory}。\");\n        }\n\n        _workflowState = CharacterDevelopmentState.SwitchCategory;\n        return StateHandlerResult.Success;\n    }\n\n    [StateHandler(CharacterDevelopmentState.FindTalentEntries, RetryTimeout = 12000, RetryInterval = 300, TransitionTimeout = 3000)]\n    private Task<StateHandlerResult> HandleFindTalentEntries(BvPage page)\n    {\n        using var capture = CaptureToRectArea();\n        if (!TryFindTalentPoints(capture, out var points))\n        {\n            return Task.FromResult(StateHandlerResult.Retry);\n        }\n\n        _talentPoints = points;\n        _talentIndex = 0;\n        _readTalentTypes.Clear();","sourceCodeStart":743,"sourceCodeEnd":779,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/CharacterDevelopment/CharacterDevelopmentTask.cs#L743-L779","documentation":"The `ReadCategory` handler only implements `Attribute` and `Weapon` (the Talent category is handled by a different state path: `FindTalentEntries`→`OpenTalent`→`ReadTalent`). Reaching `ReadCategory` with `_currentCategory` equal to `Talent` (or `None`) means the category queue/state was set up incorrectly, so it throws rather than silently skip.","triggerScenarios":"`_pendingCategories` enqueues `Talent` and the state machine routes to `ReadCategory` instead of `FindTalentEntries`; `_currentCategory` left as `None` because `SwitchCategory` dequeued into the wrong branch.","commonSituations":"A bug in `SwitchCategory`/state transition registration; a custom transition table that sends Talent to `ReadCategory`; future enum additions not wired into the switch.","solutions":["Verify `SwitchCategory` routes `Talent` to `FindTalentEntries`, not `ReadCategory`.","Keep the `ReadCategory` switch and the `SwitchCategory` routing in sync when adding categories.","If Talent reaches here, treat it as a state-machine bug and fix the transition, not the handler."],"exampleFix":"// before: default branch reached for Talent\nswitch (_currentCategory) {\n    case Attribute: await ReadAttribute(); break;\n    case Weapon: await ReadWeapon(); break;\n    default: throw new InvalidOperationException(...);\n}\n\n// after: ensure SwitchCategory sends Talent to FindTalentEntries (no handler change needed)","handlingStrategy":"try-catch","validationCode":"// Internal routing invariant; validate category queue before dispatch:\nif (_currentCategory is not (CharacterDevelopmentCategory.Attribute or CharacterDevelopmentCategory.Weapon))\n    throw new InvalidOperationException($\"无法读取分类 {_currentCategory}。\");","typeGuard":null,"tryCatchPattern":"try { await ReadCategory(page); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"无法读取分类\"))\n{ /* this is a state-machine bug; fix SwitchCategory routing for Talent */ }","preventionTips":["Keep ReadCategory's switch and SwitchCategory's routing in sync.","Route Talent to FindTalentEntries, never ReadCategory.","When adding a category, update both the switch and the transition table."],"tags":["state-machine","switch-enum","talent","routing-bug","character-development"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}