@Override public R handleExecutionException(ExecutionException ex, ParseResult parseResult) { // find top level command CommandLine cmdLine = ex.getCommandLine(); while (cmdLine.getParent() != null) { cmdLine = cmdLine.getParent(); } JetCommandLine jetCmd = cmdLine.getCommand(); if (jetCmd.isVerbose) { ex.printStackTrace(err()); } else { err().println("ERROR: " + ex.getCause().getMessage()); err().println(); err().println("To see the full stack trace, re-run with the -v/--verbose option"); } if (hasExitCode()) { exit(exitCode()); } throw ex; } }
/** Convenience method for subclasses that throws the specified ExecutionException if no exit code was set, * or otherwise, if an exit code {@linkplain #andExit(int) was set}, prints the stacktrace of the specified exception * to the diagnostic error stream and calls {@code System.exit} with the configured * exit code to terminate the currently running Java virtual machine. */ protected R throwOrExit(ExecutionException ex) { if (hasExitCode()) { ex.printStackTrace(this.err()); exit(exitCode()); } throw ex; } /** Calls {@code System.exit(int)} with the specified exit code. */
/** Convenience method for subclasses that throws the specified ExecutionException if no exit code was set, * or otherwise, if an exit code {@linkplain #andExit(int) was set}, prints the stacktrace of the specified exception * to the diagnostic error stream and calls {@code System.exit} with the configured * exit code to terminate the currently running Java virtual machine. */ protected R throwOrExit(ExecutionException ex) { if (hasExitCode()) { ex.printStackTrace(this.err()); exit(exitCode()); } throw ex; } /** Calls {@code System.exit(int)} with the specified exit code. */