{"record":{"id":"f73fd7561ca00863","repo":"babalae/better-genshin-impact","slug":"error-f73fd7","errorCode":null,"errorMessage":"截图器未初始化!","messagePattern":"截图器未初始化!","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/TaskTriggerDispatcher.cs","lineNumber":91,"sourceCode":"        public static TaskTriggerDispatcher Instance()\n        {\n            if (_instance == null)\n            {\n                throw new Exception(\"请先在启动页启动BetterGI，如果已经启动请重启\");\n            }\n\n            return _instance;\n        }\n\n        public static IGameCapture GlobalGameCapture\n        {\n            get\n            {\n                _instance = Instance();\n\n                if (_instance.GameCapture == null)\n                {\n                    throw new Exception(\"截图器未初始化!\");\n                }\n\n                return _instance.GameCapture;\n            }\n        }\n\n        public void ClearTriggers()\n        {\n            lock (_triggerListLocker)\n            {\n                GameTaskManager.ClearTriggers();\n                _triggers?.Clear();\n            }\n        }\n\n        public void SetTriggers(List<ITaskTrigger> list)\n        {\n            lock (_triggerListLocker)","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/TaskTriggerDispatcher.cs#L73-L109","documentation":"A generic Exception thrown by the TaskTriggerDispatcher.GlobalGameCapture getter when the singleton exists but its GameCapture field is null. The dispatcher is initialized but the actual screenshot/capture backend was never assigned, so any capture-dependent operation must abort.","triggerScenarios":"Accessing TaskTriggerDispatcher.GlobalGameCapture after the dispatcher singleton was created but before the capture backend (GameCapture) was set, or after it was released. Typical when capture startup failed or was cancelled.","commonSituations":"Starting a task that needs frames before the capture backend is attached; capture initialization failed silently and left GameCapture null; the user closed the capture but kept the dispatcher alive.","solutions":["On the startup page, start the screenshotter so GameCapture is assigned.","Guard capture-consuming code with a null check on the dispatcher's GameCapture before use.","If capture startup failed, restart BetterGI and re-initialize capture.","Catch the exception and show a user-facing message to start the capture."],"exampleFix":"// before\nvar cap = TaskTriggerDispatcher.GlobalGameCapture;\nvar frame = cap.Capture();\n// after\nif (TaskTriggerDispatcher.Instance().GameCapture is null)\n{\n    Toast.Warning(\"截图器未初始化\");\n    return;\n}\nvar cap = TaskTriggerDispatcher.GlobalGameCapture;","handlingStrategy":"validation","validationCode":"if (TaskTriggerDispatcher.Instance().GameCapture is null)\n{\n    Toast.Warning(\"截图器未初始化\");\n    return;\n}","typeGuard":"static bool HasCapture => TaskTriggerDispatcher.Instance().GameCapture is not null;","tryCatchPattern":"try { var cap = TaskTriggerDispatcher.GlobalGameCapture; }\ncatch (Exception ex) { Log.Warning(\"截图器未初始化: {Msg}\", ex.Message); }","preventionTips":["Start the screenshotter so GameCapture is assigned before capture-dependent code runs.","Null-check GameCapture before use.","Restart BetterGI if capture initialization failed."],"tags":["precondition","capture","initialization","dispatcher"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}