{"record":{"id":"4c04f82b3fa4cd98","repo":"babalae/better-genshin-impact","slug":"ex-getbaseexception-message","errorCode":null,"errorMessage":"切换角色：设置好感排序失败，{ex.GetBaseException().Message}","messagePattern":"切换角色：设置好感排序失败，(.+?)","errorType":"exception","errorClass":"PartySetupFailedException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/Common/Job/SwitchCharacterStateMachineTask.cs","lineNumber":1518,"sourceCode":"            SortOptionsRoi1080.X,\n            SortOptionsRoi1080.Y,\n            SortOptionsRoi1080.Width,\n            SortOptionsRoi1080.Height);\n        try\n        {\n            await page.Flow()\n                .WithDefaultTimeout(2000)\n                .WithDefaultRetryInterval(200)\n                .WaitUntilText(\"顺序\", sortTypeRoi)\n                .Click()\n                .WaitUntilText(\"好感\", sortOptionsRoi)\n                .Click()\n                .WaitUntilText(\"好感\", sortTypeRoi)\n                .Run();\n        }\n        catch (InvalidOperationException ex)\n        {\n            throw new PartySetupFailedException(\n                $\"切换角色：设置好感排序失败，{ex.GetBaseException().Message}\");\n        }\n    }\n\n    /// <summary>\n    /// 尽力点击排序方向按钮，不校验匹配或点击结果。\n    /// </summary>\n    private void ClickSortDirectionButton()\n    {\n        using var capture = CaptureToRectArea();\n        using var sortButton = capture.Find(\n            RecognitionAssets.Get(@\"Common\\Job\\SwitchCharacter\", \"SortButton\", capture));\n        if (sortButton.IsExist())\n        {\n            sortButton.Click();\n        }\n    }\n","sourceCodeStart":1500,"sourceCodeEnd":1536,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/Common/Job/SwitchCharacterStateMachineTask.cs#L1500-L1536","documentation":"EnsureFriendshipSort drives a BvPage flow to set sort mode to '好感' (friendship): wait '顺序', click, wait '好感', click, wait '好感' in the type label. An InvalidOperationException from page.Flow() (typically a WaitUntilText timeout at 2000ms) is caught and rewrapped, so the message carries the inner flow failure.","triggerScenarios":"page.Flow().WithDefaultTimeout(2000)...Run() throws InvalidOperationException because one of the WaitUntilText steps ('顺序' in SortTypeRoi, '好感' in SortOptionsRoi, or '好感' in SortTypeRoi) was not found within 2000ms.","commonSituations":"The sort UI text/ROIs (SortTypeRoi1080, SortOptionsRoi1080) do not match the current game version or scale; the sort dropdown did not open after the click; an animation exceeded the 2s per-step budget; the character list wasn't fully loaded when EnsureFriendshipSort ran.","solutions":["Read the inner message (ex.GetBaseException().Message) to identify which WaitUntilText step failed and on which ROI.","Verify SortTypeRoi1080(116,29,245,38) and SortOptionsRoi1080(111,80,241,372) against the current sort-panel layout and capture scale.","Raise WithDefaultTimeout above 2000ms if the sort UI animates slowly.","Ensure the character list is stable before entering friendship-sort (the list-open check should precede this)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await switchTask.Start(...); }\ncatch (PartySetupFailedException ex) when (ex.Message.Contains(\"设置好感排序失败\"))\n{ _logger.LogWarning(ex, \"好感排序设置失败：检查排序面板 ROI 与文本是否匹配当前版本\"); }","preventionTips":["Keep SortTypeRoi1080 / SortOptionsRoi1080 and the '顺序'/'好感' text current.","Raise WithDefaultTimeout above 2000ms if the sort UI is slow.","Ensure the character list is fully loaded before invoking EnsureFriendshipSort."],"tags":["party-setup","ui-automation","ocr","bvflow","switch-character"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}