Use the original value in the error

This commit is contained in:
Lukas Rieger (Blue) 2023-02-07 11:08:35 +01:00
parent f9bbdc3d38
commit 1d0d63f088
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2
1 changed files with 3 additions and 2 deletions

View File

@ -128,7 +128,8 @@ public class Color {
return a;
}
private static int parseColorString(String val) {
private static int parseColorString(String value) {
String val = value;
if (val.charAt(0) == '#') {
val = val.substring(1);
if (val.length() == 3) val = val + "f";
@ -136,7 +137,7 @@ public class Color {
val.charAt(0) + val.charAt(0) + val.charAt(1) + val.charAt(1) +
val.charAt(2) + val.charAt(2) + val.charAt(3) + val.charAt(3);
if (val.length() == 6) val = val + "ff";
if (val.length() != 8) throw new NumberFormatException("Invalid color format: '" + val + "'!");
if (val.length() != 8) throw new NumberFormatException("Invalid color format: '" + value + "'!");
val = val.substring(6, 8) + val.substring(0, 6); // move alpha to front
return Integer.parseUnsignedInt(val, 16);
}