{"record":{"id":"b7d24f3550b1a980","repo":"babalae/better-genshin-impact","slug":"error-b7d24f","errorCode":null,"errorMessage":"角色名不能为空。","messagePattern":"角色名不能为空。","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/CharacterDevelopment/CharacterDevelopmentTask.cs","lineNumber":154,"sourceCode":"            }\n\n            names.Add(NormalizeCharacterName(name));\n        }\n\n        if (names.Count == 0)\n        {\n            throw new ArgumentException(\"角色名集合不能为空。\", nameof(characterNames));\n        }\n\n        return names;\n    }\n\n    private static string NormalizeCharacterName(string characterName)\n    {\n        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;","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/CharacterDevelopment/CharacterDevelopmentTask.cs#L136-L172","documentation":"Thrown by NormalizeCharacterName (called from ParseCharacterNames for each name) when a character name is null, empty, or whitespace-only after trimming. Each individual name must be non-empty and meaningful.","triggerScenarios":"Called from ParseCharacterNames → NormalizeCharacterName(name). The name string is null, empty, or contains only whitespace after Trim().","commonSituations":"Array contains empty strings: ['', '钟离']; names with only spaces: ['   ']; null elements that passed the earlier 'is not string' check are impossible, but trimmed-empty strings reach here.","solutions":["Remove empty or whitespace-only entries from the array before calling.","Validate each name with a truthiness/trim check before passing.","Ensure character names are correctly typed without extra spaces."],"exampleFix":"// before (wrong)\nawait dev.GetMultiCharacters(['', '钟离']);\n// after\nawait dev.GetMultiCharacters(['钟离']);","handlingStrategy":"validation","validationCode":"// Remove empty or whitespace-only names before calling\nvar validNames = names.Where(n => !string.IsNullOrWhiteSpace(n?.ToString())).Cast<string>().ToList();","typeGuard":"static bool AllNamesNonEmpty(IEnumerable<string> names)\n{\n    return names.All(n => !string.IsNullOrWhiteSpace(n));\n}","tryCatchPattern":"try\n{\n    await dev.GetMultiCharacters(names);\n}\ncatch (ArgumentException ex) when (ex.Message.Contains(\"角色名不能为空\"))\n{\n    // Remove blank entries from the collection\n}","preventionTips":["Trim and validate each character name is non-empty before passing.","Remove empty or whitespace-only strings from the array.","Use LINQ Where(n => !string.IsNullOrWhiteSpace(n)) to filter."],"tags":["character-development","argument-validation","empty-string","normalization"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}