{"record":{"id":"6c98f572d204fe89","repo":"babalae/better-genshin-impact","slug":"maptype","errorCode":null,"errorMessage":"未知的地图类型: {mapType}","messagePattern":"未知的地图类型: (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/Common/Map/Maps/MapManager.cs","lineNumber":63,"sourceCode":"            _maps[key] = map;\n            return map;\n        }\n    }\n\n    private static ISceneMap CreateMap(MapTypes mapType, string matchingMethod)\n    {\n        if (matchingMethod == \"SIFT\")\n        {\n            return mapType switch\n            {\n                MapTypes.Teyvat => new TeyvatMap(),\n                MapTypes.TheChasm => new TheChasmMap(),\n                MapTypes.Enkanomiya => new EnkanomiyaMap(),\n                MapTypes.AncientSacredMountain => new AncientSacredMountainMap(),\n                MapTypes.SeaOfBygoneEras => new SeaOfBygoneErasMap(),\n                MapTypes.TempleOfSpace => new TempleOfSpaceMap(),\n                MapTypes.MoonCanon => new MoonCanonMap(),\n                _ => throw new System.ArgumentException($\"未知的地图类型: {mapType}\", nameof(mapType))\n            };\n        }\n        else\n        {\n            return mapType switch\n            {\n                MapTypes.Teyvat => new TeyvatMapTest(),\n                MapTypes.TheChasm => new TheChasmMapTest(),\n                MapTypes.Enkanomiya => new EnkanomiyaMapTest(),\n                MapTypes.AncientSacredMountain => new AncientSacredMountainMap(),\n                MapTypes.SeaOfBygoneEras => new SeaOfBygoneErasMap(),\n                MapTypes.TempleOfSpace => new TempleOfSpaceMap(),\n                MapTypes.MoonCanon => new MoonCanonMap(),\n                _ => throw new System.ArgumentException($\"未知的地图类型: {mapType}\", nameof(mapType))\n            };\n        }\n    }\n}","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/Common/Map/Maps/MapManager.cs#L45-L81","documentation":"Thrown by MapManager.CreateMap in the SIFT matching-method branch when mapType is not one of the handled enum values (Teyvat, TheChasm, Enkanomiya, AncientSacredMountain, SeaOfBygoneEras, TempleOfSpace, MoonCanon). The switch's default arm throws ArgumentException. This is a defensive exhaustiveness check — every defined MapTypes member is handled, so it fires only for an out-of-range/undefined enum value.","triggerScenarios":"GetMap(mapType, \"SIFT\") is called with an enum value outside the known set. Since MapTypes is a closed enum and all members are listed, this requires either an invalid cast (e.g. (MapTypes)999) or a newly added enum member whose SIFT map class hasn't been implemented yet.","commonSituations":"A new MapTypes member was added to the enum but no corresponding 'new XxxMap()' case was added in the SIFT branch; an external caller cast an arbitrary int to MapTypes; config/job data referenced a map type code that mapped to an undefined enum value.","solutions":["If you added a new MapTypes member, add its case to both switch expressions in CreateMap (lines 54 and 68).","Validate the mapType value is a defined enum member before calling GetMap (Enum.IsDefined).","Check the originating config/pathing data for an invalid map-type code and correct it to a supported value."],"exampleFix":"// before\n_ => throw new System.ArgumentException($\"未知的地图类型: {mapType}\", nameof(mapType))\n\n// after — keep the guard, but ensure every enum member is mapped; if you just added a member add its case:\nMapTypes.NewRegion => new NewRegionMap(),\n_ => throw new System.ArgumentException($\"未知的地图类型: {mapType}\", nameof(mapType))","handlingStrategy":"type-guard","validationCode":"if (!Enum.IsDefined(mapType)) throw new ArgumentException($\"无效的地图类型枚举值: {mapType}\");","typeGuard":"static bool IsKnownSiftMapType(MapTypes t) => t is MapTypes.Teyvat or MapTypes.TheChasm or MapTypes.Enkanomiya or MapTypes.AncientSacredMountain or MapTypes.SeaOfBygoneEras or MapTypes.TempleOfSpace or MapTypes.MoonCanon;","tryCatchPattern":null,"preventionTips":["When adding a MapTypes member, add its case to both switch expressions in CreateMap.","Validate enum values at the config boundary before calling GetMap."],"tags":["map-manager","enum","switch-exhaustiveness","config"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}