find root exception

This commit is contained in:
Peter Hormanns 2013-11-04 17:28:41 +01:00
parent 2d4bb80ac6
commit e4157cbfb8

View File

@ -43,8 +43,9 @@ public class Main {
try {
scriptClient.execute(command);
console.println(formatter.format(scriptClient.getLastRpcResult()));
} catch (Exception e) {
console.println("Error: " + e.getLocalizedMessage() + "\n");
} catch (JSCliException e) {
final String errorMessage = createErrorMessage(e);
console.println(errorMessage + "\n");
}
command = console.readInput();
}
@ -55,4 +56,17 @@ public class Main {
}
}
private static String createErrorMessage(final JSCliException e) {
String errorMessage = "Error: " + e.getLocalizedMessage();
Throwable cause = e;
while (cause.getCause() != null) {
cause = cause.getCause();
}
errorMessage = cause.getLocalizedMessage();
if (errorMessage.contains("de.hsadmin.rpc.VOUserException:")) {
errorMessage = errorMessage.substring(errorMessage.indexOf("de.hsadmin.rpc.VOUserException:") + 31).trim();
}
return errorMessage;
}
}