Skip to content

Commit

Permalink
Improve error message.
Browse files Browse the repository at this point in the history
  • Loading branch information
raphw committed Dec 7, 2024
1 parent e8dd11e commit 0856b28
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2507,7 +2507,7 @@ public FieldVisitor visitField(int modifiers, String name, String descriptor, @M
type = String.class;
}
if (!type.isInstance(value)) {
throw new IllegalStateException("Field " + name + " defines an incompatible default value " + value);
throw new IllegalStateException("Field " + name + " defines an incompatible default value " + value + " (" + value.getClass().getName() + ")");
} else if (type == Integer.class) {
int minimum, maximum;
switch (descriptor.charAt(0)) {
Expand All @@ -2532,7 +2532,7 @@ public FieldVisitor visitField(int modifiers, String name, String descriptor, @M
maximum = Integer.MAX_VALUE;
}
if ((Integer) value < minimum || (Integer) value > maximum) {
throw new IllegalStateException("Field " + name + " defines an incompatible default value " + value);
throw new IllegalStateException("Field " + name + " defines an incompatible default value " + value + " (" + minimum + "-" + maximum + ")");
}
}
}
Expand Down

0 comments on commit 0856b28

Please sign in to comment.