babalae/better-genshin-impact · error · ArgumentException

未知的角色信息分类:{rawCategory}

Error message

未知的角色信息分类:{rawCategory}

What it means

Thrown by ParseCategories when splitting the categories string by ';' yields a token that doesn't match any known category. Valid categories are '属性' (Attribute), '武器' (Weapon), '天赋' (Talent). Any other token (including typos or English names) triggers this ArgumentException.

Source

Thrown at BetterGenshinImpact/GameTask/CharacterDevelopment/CharacterDevelopmentTask.cs:181

        {
            return CharacterDevelopmentCategory.All;
        }

        if (string.IsNullOrWhiteSpace(categories))
        {
            throw new ArgumentException("读取分类不能为空字符串。", nameof(categories));
        }

        CharacterDevelopmentCategory result = CharacterDevelopmentCategory.None;
        foreach (var rawCategory in categories.Split(';', StringSplitOptions.None))
        {
            var category = rawCategory.Trim();
            result |= category switch
            {
                "属性" => CharacterDevelopmentCategory.Attribute,
                "武器" => CharacterDevelopmentCategory.Weapon,
                "天赋" => CharacterDevelopmentCategory.Talent,
                _ => throw new ArgumentException($"未知的角色信息分类:{rawCategory}", nameof(categories))
            };
        }

        return result;
    }
}

internal enum CharacterDevelopmentState
{
    Unknown,
    MainUi,
    OpenCharacterList,
    OpenFilterPanel,
    FilterPanel,
    SelectElementFilter,
    SelectWeaponFilter,
    ConfirmFilterPanel,
    FindAndClickAvatar,

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Use only valid category names: '属性', '武器', '天赋' (semicolon-separated).
  2. Check for typos or encoding issues in the category string.
  3. Remove extra semicolons or empty tokens from the input.
  4. Pass null for all categories if unsure.

Example fix

// before (wrong)
await dev.GetMultiCharacters(['钟离'], '属性;Talent');
// after
await dev.GetMultiCharacters(['钟离'], '属性;天赋');
Defensive patterns

Strategy: validation

Validate before calling

// Validate category tokens before calling
var validCategories = new HashSet<string> { "属性", "武器", "天赋" };
if (categories != null)
{
    foreach (var token in categories.Split(';'))
    {
        if (!validCategories.Contains(token.Trim()))
        {
            throw new ArgumentException($"Invalid category: {token}. Valid: 属性, 武器, 天赋");
        }
    }
}

Type guard

static bool IsValidCategoryString(string? categories)
{
    if (categories == null) return true;
    if (string.IsNullOrWhiteSpace(categories)) return false;
    var valid = new HashSet<string> { "属性", "武器", "天赋" };
    return categories.Split(';').All(t => valid.Contains(t.Trim()));
}

Try / catch

try
{
    await dev.GetMultiCharacters(names, categories);
}
catch (ArgumentException ex) when (ex.Message.Contains("未知的角色信息分类"))
{
    // Use only valid categories: 属性, 武器, 天赋
}

Prevention

When it happens

Trigger: Called from ParseCategories. categories.Split(';') produces a token that, after trimming, doesn't match '属性', '武器', or '天赋' in the switch expression default arm.

Common situations: Typo in category name (e.g. '属' instead of '属性'); using English names (e.g. 'Talent') instead of Chinese; extra semicolons producing empty tokens that should have been filtered; game version added new categories not yet supported.

Related errors


AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13). Data as JSON: /api/errors/457bb515555e3ad7. Report an issue: GitHub.