@@ -0,0 +1,1783 @@
+package org.kohsuke.args4j;%0A%0A// a 'custom' exception%0Aimport javax.management.InvalidAttributeValueException;%0A%0A%0Apublic class CustomExceptionTest extends Args4JTestBase%3CCustomExceptionTest%3E %7B%0A%0A    private String errMsgX = %22this is a usual CLI exception%22;%0A    private String errMsgY = %22this is a 'custom' exception%22;%0A%0A%0A    @Option(name=%22-x%22)%0A    public void setX(String x) %7B%0A        throw new IllegalArgumentException(errMsgX);%0A    %7D%0A    %0A    @Option(name=%22-y%22)%0A    public void setY(String y) throws InvalidAttributeValueException %7B%0A        throw new InvalidAttributeValueException(errMsgX);%0A    %7D%0A%0A%0A    @Override%0A    public CustomExceptionTest getTestObject() %7B%0A        return this;%0A    %7D%0A    %0A    %0A    protected void tryThis(String expected, Class expectedExceptionClass, String... parserArgs) %7B%0A        String expMsg = expectedExceptionClass.getName() + %22: %22 + expected;%0A        try %7B%0A            parser.parseArgument(parserArgs);%0A            fail(%22Exception expected.%22);%0A        %7D catch (RuntimeException e) %7B%0A            // RuntimeExceptions are passed through the parser to the caller.%0A            assertEquals(%22Lost exception message.%22, expMsg, e.toString());%0A        %7D catch (CmdLineException e) %7B%0A            // Other Exceptions are wrapped into a CLE so we must ensure not to loose the%0A            // message.%0A            assertEquals(%22Lost exception message.%22, expMsg, e.getMessage());%0A        %7D catch (Exception e) %7B%0A            fail(%22Wrong exception type thrown.%22);%0A        %7D%0A    %7D%0A    %0A    public void testRuntimeException() throws Exception %7B%0A        tryThis(errMsgX, IllegalArgumentException.class, %22-x%22, %22value%22);%0A    %7D%0A    %0A    public void testCustomException() throws Exception %7B%0A        tryThis(errMsgX, InvalidAttributeValueException.class, %22-y%22, %22value%22);%0A    %7D%0A%0A%7D

Add a test how to handle thrown exceptions thrown in setters.