@Test public void testCall1DefaultExceptionHandlerRethrows() { try { CommandLine.call(new MyCallable(), "-x abc"); } catch (ExecutionException ex) { String cmd = ex.getCommandLine().getCommand().toString(); String msg = "Error while calling command (" + cmd + "): java.lang.IllegalStateException: this is a test"; assertEquals(msg, ex.getMessage()); } assertEquals("", systemErrRule.getLog()); assertEquals("", systemOutRule.getLog()); }
@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; } }
@Test public void testCall1DefaultExceptionHandlerRethrows() { try { CommandLine.call(new MyCallable(), "-x abc"); } catch (ExecutionException ex) { String cmd = ex.getCommandLine().getCommand().toString(); String msg = "Error while calling command (" + cmd + "): java.lang.IllegalStateException: this is a test"; assertEquals(msg, ex.getMessage()); } assertEquals("", systemErrRule.getLog()); assertEquals("", systemOutRule.getLog()); }