Skip to content

Commit

Permalink
Improved error message for DuplicateOptionAnnotationsException. Closes
Browse files Browse the repository at this point in the history
  • Loading branch information
remkop committed Apr 18, 2017
1 parent c4ee144 commit efde066
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/main/java/picocli/CommandLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -3193,8 +3193,9 @@ public DuplicateOptionAnnotationsException(String msg) {
}

private static DuplicateOptionAnnotationsException create(String name, Field field1, Field field2) {
return new DuplicateOptionAnnotationsException("Option name '" + name + "' is used in both "
+ field1.getName() + " and " + field2.getName());
return new DuplicateOptionAnnotationsException("Option name '" + name + "' is used by both " +
field1.getDeclaringClass().getName() + "." + field1.getName() + " and " +
field2.getDeclaringClass().getName() + "." + field2.getName());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/picocli/CommandLineTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1684,7 +1684,7 @@ class ChildOption extends ParentOption {
CommandLine.parse(new ChildOption(), "");
fail("expected CommandLine$DuplicateOptionAnnotationsException");
} catch (DuplicateOptionAnnotationsException ex) {
assertEquals("Option name '-p' is used in both path and text", ex.getMessage());
assertEquals("Option name '-p' is used by both picocli.CommandLineTest$2ParentOption.path and picocli.CommandLineTest$2ChildOption.text", ex.getMessage());
}
}

Expand Down

0 comments on commit efde066

Please sign in to comment.