{"record":{"id":"8905cc22b6ba1fe1","repo":"babalae/better-genshin-impact","slug":"error-8905cc","errorCode":null,"errorMessage":"最终合成个数读取失败。","messagePattern":"最终合成个数读取失败。","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/Common/Job/CraftMaterialTask.cs","lineNumber":442,"sourceCode":"        while (actualQuantity < targetQuantity)\n        {\n            GameCaptureRegion.GameRegion1080PPosClick(addButton.X, addButton.Y);\n            await Delay(60, _ct);\n            actualQuantity++;\n        }\n\n        while (actualQuantity > targetQuantity)\n        {\n            GameCaptureRegion.GameRegion1080PPosClick(reduceButton.X, reduceButton.Y);\n            await Delay(60, _ct);\n            actualQuantity--;\n        }\n\n        await Delay(200, _ct);\n        var verifiedQuantity = ReadCurrentCraftQuantity();\n        if (verifiedQuantity <= 0)\n        {\n            throw new InvalidOperationException(\"最终合成个数读取失败。\");\n        }\n\n        if (verifiedQuantity != targetQuantity)\n        {\n            throw new InvalidOperationException($\"最终合成个数与目标不一致，目标 {targetQuantity}，当前 {verifiedQuantity}。\");\n        }\n\n        return verifiedQuantity;\n    }\n\n    /// <summary>\n    /// 读取右侧当前合成个数。\n    /// </summary>\n    /// <returns>识别到的当前合成个数；失败时返回 0。</returns>\n    private int ReadCurrentCraftQuantity()\n    {\n        var text = StringUtils.ConvertFullWidthNumToHalfWidth(ReadOcrText(Rect1080(1248, 615, 221, 34)));\n        return ReadFirstPositiveInt(text);","sourceCodeStart":424,"sourceCodeEnd":460,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/Common/Job/CraftMaterialTask.cs#L424-L460","documentation":"Thrown at the final verification step after the add/reduce fine-tuning loops when ReadCurrentCraftQuantity() again returns a non-positive value. The fine-tuning clicks (addButton 1614,672 / reduceButton 1074,672) are assumed to have landed, but the OCR field can no longer be read.","triggerScenarios":"After the while-loops that click add/reduce buttons, ReadCurrentCraftQuantity() on Rect1080(1248,615,221,34) returns 0. Happens if a click strayed (e.g. opened another panel, dismissed the field), the capture is mid-transition, or OCR regressed.","commonSituations":"A fine-tune click hit a different UI element and closed/changed the craft panel; the 200ms post-click delay is too short for the number to re-render; resolution drift moved the field off the crop.","solutions":["Lengthen the Delay(200) before the final read so the quantity field fully re-renders after button clicks.","Confirm the add/reduce button coordinates (1614,672 / 1074,672) still sit on the actual buttons at the current scale.","Re-read once after a longer delay before throwing.","Guard the fine-tune loops so a click that changes the UI is detected (e.g. re-check we are still on the craft panel)."],"exampleFix":"// before\nawait Delay(200, _ct);\nvar verifiedQuantity = ReadCurrentCraftQuantity();\nif (verifiedQuantity <= 0)\n{\n    throw new InvalidOperationException(\"最终合成个数读取失败。\");\n}\n\n// after: one longer-delay re-read\nawait Delay(200, _ct);\nvar verifiedQuantity = ReadCurrentCraftQuantity();\nif (verifiedQuantity <= 0)\n{\n    await Delay(400, _ct);\n    verifiedQuantity = ReadCurrentCraftQuantity();\n}\nif (verifiedQuantity <= 0)\n{\n    throw new InvalidOperationException(\"最终合成个数读取失败。\");\n}","handlingStrategy":"retry","validationCode":"null","typeGuard":"null","tryCatchPattern":"try { await SetCraftQuantity(target); }\ncatch (InvalidOperationException e) when (e.Message.Contains(\"最终合成个数读取失败\"))\n{ /* re-capture after a longer delay and re-read */ }","preventionTips":["Ensure the post-fine-tune delay is long enough for the field to re-render.","Confirm the add/reduce button coordinates are on the buttons at the current scale.","Re-read OCR once more after a longer wait before declaring failure."],"tags":["ocr","crafting","verification","genshin-ui"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}