babalae/better-genshin-impact · error · ArgumentOutOfRangeException
未知角色信息分类。
Error message
未知角色信息分类。
What it means
`GetCategoryText` maps each `CharacterDevelopmentCategory` flag to its Chinese tab label and throws `ArgumentOutOfRangeException` for any unmapped value. With Attribute/Weapon/Talent all handled, the default is unreachable unless a new enum member is added without updating the switch or an invalid flag combination (a numeric cast) is passed.
Source
Thrown at BetterGenshinImpact/GameTask/CharacterDevelopment/CharacterDevelopmentTask.cs:1220
{
var captureRect = TaskContext.Instance().SystemInfo.ScaleMax1080PCaptureRect;
return new Rect(0, 0, (int)(captureRect.Width * 0.2), captureRect.Height);
}
private static Rect GetTalentListRoi(ImageRegion capture)
{
var x = (int)(capture.Width * 0.8);
return new Rect(x, 0, capture.Width - x, capture.Height);
}
private static string GetCategoryText(CharacterDevelopmentCategory category)
{
return category switch
{
CharacterDevelopmentCategory.Attribute => "属性",
CharacterDevelopmentCategory.Weapon => "武器",
CharacterDevelopmentCategory.Talent => "天赋",
_ => throw new ArgumentOutOfRangeException(nameof(category), category, "未知角色信息分类。")
};
}
}
View on GitHub (pinned to a7cb36712d)
Solutions
- When adding a category, update `GetCategoryText`, `GetOrderedCategories`, and the `ReadCategory` switch together.
- Ensure only valid, set flags reach `GetCategoryText` (filter `None` upstream).
- In tests, pass real enum members, not arbitrary casts.
Example fix
// before GetCategoryText((CharacterDevelopmentCategory)99); // throws // after: pass a real flag GetCategoryText(CharacterDevelopmentCategory.Attribute);
Defensive patterns
Strategy: type-guard
Type guard
static bool IsKnownCategory(CharacterDevelopmentCategory c) =>
c == CharacterDevelopmentCategory.Attribute
|| c == CharacterDevelopmentCategory.Weapon
|| c == CharacterDevelopmentCategory.Talent; Prevention
- Filter None upstream so only set, known flags reach GetCategoryText.
- When adding a category, update GetCategoryText, GetOrderedCategories, and ReadCategory together.
- In tests, pass real enum members, not arbitrary integer casts.
When it happens
Trigger: A future `CharacterDevelopmentCategory` member not handled in the switch; an explicitly cast invalid integer passed as the category; `None` reaching this function (it is normally filtered earlier).
Common situations: Enum extension without updating all exhaustiveness switches; tests passing `default`/`(CharacterDevelopmentCategory)999`.
Related errors
- 未知天赋类型:{type}
- 无法读取分类 {_currentCategory}。
- 天赋点击位置索引越界。
- 多角色接口需要字符串集合或 JS Array,单个字符串请使用 GetCharacter。
- 角色名参数必须是字符串集合或 JS Array。
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/37d289e579e8324e.
Report an issue: GitHub.