{"record":{"id":"5e8a955c90011bb9","repo":"babalae/better-genshin-impact","slug":"error-5e8a95","errorCode":null,"errorMessage":"读取分类不能为空字符串。","messagePattern":"读取分类不能为空字符串。","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/CharacterDevelopment/CharacterDevelopmentTask.cs","lineNumber":169,"sourceCode":"        var name = characterName?.Trim() ?? string.Empty;\n        if (string.IsNullOrWhiteSpace(name))\n        {\n            throw new ArgumentException(\"角色名不能为空。\", nameof(characterName));\n        }\n\n        return name;\n    }\n\n    internal static CharacterDevelopmentCategory ParseCategories(string? categories)\n    {\n        if (categories == null)\n        {\n            return CharacterDevelopmentCategory.All;\n        }\n\n        if (string.IsNullOrWhiteSpace(categories))\n        {\n            throw new ArgumentException(\"读取分类不能为空字符串。\", nameof(categories));\n        }\n\n        CharacterDevelopmentCategory result = CharacterDevelopmentCategory.None;\n        foreach (var rawCategory in categories.Split(';', StringSplitOptions.None))\n        {\n            var category = rawCategory.Trim();\n            result |= category switch\n            {\n                \"属性\" => CharacterDevelopmentCategory.Attribute,\n                \"武器\" => CharacterDevelopmentCategory.Weapon,\n                \"天赋\" => CharacterDevelopmentCategory.Talent,\n                _ => throw new ArgumentException($\"未知的角色信息分类：{rawCategory}\", nameof(categories))\n            };\n        }\n\n        return result;\n    }\n}","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/CharacterDevelopment/CharacterDevelopmentTask.cs#L151-L187","documentation":"Thrown by ParseCategories when the categories argument is a non-null string that is empty or whitespace-only. Null is treated as 'all categories', but an explicitly empty string is ambiguous and rejected. Pass null for 'all' or provide valid category names.","triggerScenarios":"Called from GetMultiCategories or GetMultiCharacters → ParseCategories(categories). categories is a non-null string where string.IsNullOrWhiteSpace returns true.","commonSituations":"Caller passes '' or '   ' explicitly instead of null; a variable intended to be null is initialized to empty string; configuration value defaults to empty string.","solutions":["Pass null instead of an empty string to select all categories.","Pass a valid category string like '属性;武器;天赋' for specific categories.","Fix upstream code that produces empty strings where null is expected."],"exampleFix":"// before (wrong)\nawait dev.GetMultiCharacters(['钟离'], '');\n// after (all categories)\nawait dev.GetMultiCharacters(['钟离'], null);\n// after (specific categories)\nawait dev.GetMultiCharacters(['钟离'], '属性;天赋');","handlingStrategy":"validation","validationCode":"// Pass null for all categories, or a valid string\nstring? safeCategories = string.IsNullOrWhiteSpace(categories) ? null : categories;\nawait dev.GetMultiCharacters(names, safeCategories);","typeGuard":null,"tryCatchPattern":"try\n{\n    await dev.GetMultiCharacters(names, categories);\n}\ncatch (ArgumentException ex) when (ex.Message.Contains(\"读取分类不能为空\"))\n{\n    // Pass null instead of empty string\n}","preventionTips":["Pass null (not empty string) to select all categories.","Normalize empty strings to null before calling ParseCategories.","Use a helper: categories = string.IsNullOrWhiteSpace(c) ? null : c."],"tags":["character-development","argument-validation","categories","empty-string"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}