fix error handling
This commit is contained in:
parent
43d542d63b
commit
ba45fc8886
@ -75,6 +75,12 @@ public class Main {
|
||||
for (String ll : lines) {
|
||||
console.println(ll);
|
||||
}
|
||||
} catch (RuntimeException re) {
|
||||
if (re.getCause() instanceof JSCliException) {
|
||||
console.println(findRootException(re.getCause()));
|
||||
} else {
|
||||
throw re;
|
||||
}
|
||||
} catch (JSCliException e) {
|
||||
console.println(findRootException(e));
|
||||
}
|
||||
@ -92,7 +98,7 @@ public class Main {
|
||||
return "bye".equals(trimmedCommand) || "exit".equals(trimmedCommand) || "quit".equals(trimmedCommand);
|
||||
}
|
||||
|
||||
private static String findRootException(final Exception exp) {
|
||||
private static String findRootException(final Throwable exp) {
|
||||
Throwable cause = exp;
|
||||
while (cause.getCause() != null && cause.getCause() != cause) {
|
||||
cause = cause.getCause();
|
||||
|
Loading…
Reference in New Issue
Block a user