-
Notifications
You must be signed in to change notification settings - Fork 446
Closed
Labels
Milestone
Description
When an exception occurs in the business logic, this is handled by the execution exception handler. By default, this prints the full stack trace of the exception.
Since 4.3.0, only the stack trace of the "outer" exception is printed. If that exception has any "cause" exceptions, these are incorrectly omitted.
With the work done in #484, #845 and #1008 (colors in exception handler), we no longer call exception.printStackTrace() but instead have a custom implementation that has the same effect but uses ANSI colors. This implementation incorrectly omits the stack trace for any nested "cause" exceptions (and their nested cause, if any).
A workaround is to register a custom execution exception handler as follows:
new CommandLine(new MyApp())
.setExecutionExceptionHandler(
(Exception ex, CommandLine commandLine, ParseResult parseResult) -> {
ex.printStackTrace();
return commandLine.getCommandSpec().exitCodeOnExecutionException();
})
.execute(args);