HMCL-dev/HMCL · error · IllegalArgumentException
Unsupported theme brightness:
Error message
Unsupported theme brightness:
What it means
Raised in parseBrightness() (called from readBrightness) when the serialized brightness string in the theme manifest does not match any known brightness token (e.g. dark/light or a recognized level name). Only enumerated brightness names are accepted; an arbitrary or misspelled token is rejected. The input at fault is the brightness field's string value.
Solutions
- Use one of the supported brightness tokens (e.g. "dark", "light") in the theme manifest.
- Fix the typo or casing of the brightness value so it matches a known token.
- Remove the brightness field to fall back to the default brightness.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemeAppearance.java:378 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of HMCL-dev/HMCL@24702dc5a0 (2026-09-10).
Data as JSON: /api/errors/5a68fd2f0066eb2d.
Report an issue: GitHub.
Appendix: source
Thrown at HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemeAppearance.java:378
if (contrast.equals(Contrast.LOW)) {
object.addProperty(FIELD_CONTRAST, "low");
} else if (contrast.equals(Contrast.DEFAULT)) {
object.addProperty(FIELD_CONTRAST, "standard");
} else if (contrast.equals(Contrast.MEDIUM)) {
object.addProperty(FIELD_CONTRAST, "medium");
} else if (contrast.equals(Contrast.HIGH)) {
object.addProperty(FIELD_CONTRAST, "high");
} else {
object.addProperty(FIELD_CONTRAST, contrast.getValue());
}
}
/// Parses a serialized theme brightness value.
private static Brightness parseBrightness(String value) {
return switch (value.trim().toLowerCase(Locale.ROOT)) {
case "light" -> Brightness.LIGHT;
case "dark" -> Brightness.DARK;
default -> throw new IllegalArgumentException("Unsupported theme brightness: " + value);
};
}
/// Converts a controlled brightness value to its canonical JSON string.
private static String toJsonBrightness(Brightness brightness) {
return switch (brightness) {
case LIGHT -> "light";
case DARK -> "dark";
};
}
}
View on GitHub (pinned to 24702dc5a0)