In my recent programming adventures, I separately encountered two perplexing error messages:
RuntimeException: Variable is used without definition!
IllegalArgumentException: Duplicate field expected
Inspection of the underlying code brought clarity:
throw new RuntimeException("Variable " + m + " used without definition!");
throw new IllegalArgumentException("Duplicate field " + fieldName);
The former was reporting a problem with a variable declared as
InputStream is, the latter a problem with JUnit’s
@Test annotation which defines a parameter
java.lang.Class<? extends java.lang.Throwable> expected.
Tip from the pros: always wrap identifiers in quotes when including them in error messages.