{"record":{"id":"4cbf42deba2e2b38","repo":"babalae/better-genshin-impact","slug":"name-4cbf42","errorCode":null,"errorMessage":"无法找到名称为 '{name}' 的枚举值","messagePattern":"无法找到名称为 '(.+?)' 的枚举值","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"warning","filePath":"BetterGenshinImpact/GameTask/Common/Map/Maps/Base/MapTypes.cs","lineNumber":52,"sourceCode":"        {\n            if (Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) is DescriptionAttribute attribute)\n            {\n                if (attribute.Description == description)\n                {\n                    return (MapTypes)field.GetValue(null)!;\n                }\n            }\n        }\n        throw new ArgumentException($\"无法找到描述为 '{description}' 的枚举值\", nameof(description));\n    }\n    \n    public static MapTypes ParseFromName(string name)\n    {\n        if (Enum.TryParse<MapTypes>(name, true, out var result))\n        {\n            return result;\n        }\n        throw new ArgumentException($\"无法找到名称为 '{name}' 的枚举值\", nameof(name));\n    }\n}","sourceCodeStart":34,"sourceCodeEnd":54,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/Common/Map/Maps/Base/MapTypes.cs#L34-L54","documentation":"Thrown by MapTypesExtensions.ParseFromName when Enum.TryParse<MapTypes>(name, true, out var result) fails. The parse is case-insensitive (ignoreCase=true), so it fails only when 'name' is not the textual representation of any MapTypes member (e.g. 'Teyvat', 'TheChasm'). Used to convert a map-type name string to the enum.","triggerScenarios":"ParseFromName receives a string that is not a member name (case-insensitive). MapManager.GetMap(string mapName,...) calls ParseFromName(mapName), so any external/config map name that isn't a valid enum member name triggers this.","commonSituations":"Config or pathing JSON uses a map name like 'teyvat大陆' or a description instead of the enum name; a renamed/removed member; typos; whitespace in the name; full-width vs half-width characters.","solutions":["Use the exact enum member name (e.g. 'Teyvat', 'TheChasm') in config; the parse is case-insensitive so casing is flexible.","Trim the input and verify against Enum.GetNames<MapTypes>().","If you intended to pass a human label (description), call ParseFromDescription instead.","Add validation/warning when the name isn't recognized before it reaches this throw."],"exampleFix":"// before — throws on bad input\npublic static MapTypes ParseFromName(string name)\n{\n    if (Enum.TryParse<MapTypes>(name, true, out var result)) return result;\n    throw new ArgumentException(...);\n}\n\n// after — accept both names and descriptions, and trim\npublic static MapTypes ParseFromName(string name)\n{\n    if (Enum.TryParse<MapTypes>(name?.Trim(), true, out var result)) return result;\n    // fall back to description match\n    return ParseFromDescription(name!.Trim());\n}","handlingStrategy":"validation","validationCode":"if (!Enum.TryParse<MapTypes>(name?.Trim(), true, out _))\n    throw new ArgumentException($\"无效的地图名称: {name}，可用值: {string.Join(\", \", Enum.GetNames<MapTypes>())}\");","typeGuard":"static bool IsValidMapName(string? n) => Enum.TryParse<MapTypes>(n?.Trim(), true, out _);","tryCatchPattern":null,"preventionTips":["Use exact enum member names in config (case-insensitive).","Validate at the config load boundary and report valid options."],"tags":["enum","parsing","config","enum-tryparse"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}