-
- Enclosing class:
- CommandLine
public static interface CommandLine.IExitCodeExceptionMapper
Interface that provides the appropriate exit code that will be returned from theexecute
method for an exception that occurred during parsing or while invoking the command's Runnable, Callable, or Method.Example usage:
@Command class FailingCommand implements Callable<Void> { public Void call() throws IOException { throw new IOException("error"); } } IExitCodeExceptionMapper mapper = new IExitCodeExceptionMapper() { public int getExitCode(Throwable t) { if (t instanceof IOException && "error".equals(t.getMessage())) { return 123; } return 987; } } CommandLine cmd = new CommandLine(new FailingCommand()); cmd.setExitCodeExceptionMapper(mapper); int exitCode = cmd.execute(args); assert exitCode == 123; System.exit(exitCode);
- Since:
- 4.0
- See Also:
CommandLine.setExitCodeExceptionMapper(IExitCodeExceptionMapper)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
getExitCode(Throwable exception)
Returns the exit code that should be returned from theexecute
method.
-