{"record":{"id":"0a2a9a49641d5a2b","repo":"babalae/better-genshin-impact","slug":"error-0a2a9a","errorCode":null,"errorMessage":"不支持的相对鼠标输入类型","messagePattern":"不支持的相对鼠标输入类型","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/Core/Monitor/RelativeMouseInputMonitorFactory.cs","lineNumber":15,"sourceCode":"using System;\n\nnamespace BetterGenshinImpact.Core.Monitor;\n\npublic sealed class RelativeMouseInputMonitorFactory(\n    DirectInputMonitor directInputMonitor,\n    RawInputMonitor rawInputMonitor) : IRelativeMouseInputMonitorFactory\n{\n    public IRelativeMouseInputMonitor Get(RelativeMouseInputType type)\n    {\n        return type switch\n        {\n            RelativeMouseInputType.DirectInput => directInputMonitor,\n            RelativeMouseInputType.RawInput => rawInputMonitor,\n            _ => throw new ArgumentOutOfRangeException(nameof(type), type, \"不支持的相对鼠标输入类型\")\n        };\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":19,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/Core/Monitor/RelativeMouseInputMonitorFactory.cs#L1-L19","documentation":"RelativeMouseInputMonitorFactory.Get maps a RelativeMouseInputType to a concrete monitor (DirectInput or RawInput). Any other value (including default(int) cast to the enum, or a future enum member) hits the default arm and throws ArgumentOutOfRangeException. This is a closed-enum guard ensuring only the two supported backends are selected.","triggerScenarios":"Passing an unconfigured/default RelativeMouseInputType; reading the type from config that was never set; an enum value added without updating the factory.","commonSituations":"Default-initialized config object whose MouseInputType field defaults to 0 (not a valid member); config schema drift; new enum member added to RelativeMouseInputType but not handled here.","solutions":["Ensure config always specifies a valid RelativeMouseInputType (DirectInput or RawInput).","Validate the enum value at config load and default to a supported backend.","When extending the enum, update this switch in the same change."],"exampleFix":"// before\nvar mon = factory.Get(config.RelativeMouseType);\n\n// after\nvar type = config.RelativeMouseType is RelativeMouseInputType.DirectInput\n    or RelativeMouseInputType.RawInput\n        ? config.RelativeMouseType\n        : RelativeMouseInputType.DirectInput;\nvar mon = factory.Get(type);","handlingStrategy":"validation","validationCode":"var type = config.RelativeMouseType is RelativeMouseInputType.DirectInput\n    or RelativeMouseInputType.RawInput\n        ? config.RelativeMouseType\n        : RelativeMouseInputType.DirectInput;\nvar mon = factory.Get(type);","typeGuard":"static bool IsSupported(RelativeMouseInputType t) => t is RelativeMouseInputType.DirectInput or RelativeMouseInputType.RawInput;","tryCatchPattern":null,"preventionTips":["Validate the enum at config load and default to a supported backend.","Keep the factory switch exhaustive when adding enum members.","Avoid default(int)->enum casts from untrusted config."],"tags":["mouse","factory","enum","argument-validation","monitor"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}