Skip to content

Commit

Permalink
Fix for WFCORE-3225. CLI exception, keep calling stack
Browse files Browse the repository at this point in the history
  • Loading branch information
jfdenise committed Sep 18, 2017
1 parent 8f91885 commit 29bed5f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
18 changes: 11 additions & 7 deletions cli/src/main/java/org/jboss/as/cli/impl/CommandContextImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -829,12 +829,7 @@ private <T> T execute(Callable<T> c, String msg) throws CommandLineException {
Thread.currentThread().interrupt();
throw new CommandLineException("Interrupt exception for " + msg);
} catch (ExecutionException ex) {
Throwable cause = ex.getCause() == null ? ex : ex.getCause();
if (cause instanceof CommandLineException) {
throw (CommandLineException) cause;
}
throw new CommandLineException("Execution exception for " + msg
+ ": " + cause.getMessage(), cause);
throw new CommandLineException(ex);
} catch (CommandLineException ex) {
throw ex;
} catch (Exception ex) {
Expand All @@ -846,7 +841,16 @@ public void handleSafe(String line) {
exitCode = 0;
try {
handle(line);
} catch(Throwable t) {
} catch (Throwable t) {
// Remove exceptions that are wrappers to not pollute error message.
if (t instanceof CommandLineException
&& t.getCause() instanceof ExecutionException) {
// Get the ExecutionException cause.
Throwable cause = t.getCause().getCause();
if (cause != null) {
t = cause;
}
}
error(Util.getMessagesFromThrowable(t));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ protected void assertConflicts(CommandLineException e, String... conflicts) {
buf.append(", ");
}
}
assertEquals(e.getMessage().split(System.getProperty("line.separator"))[0], buf.toString());
String msg = e.getMessage().substring(e.getMessage().indexOf(PatchLogger.ROOT_LOGGER.detectedConflicts()));
assertEquals(msg.split(System.getProperty("line.separator"))[0], buf.toString());
}
}

0 comments on commit 29bed5f

Please sign in to comment.