Skip to content

Commit

Permalink
#2800: Report inner exceptions for more context on failures
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyeeedar committed May 6, 2020
1 parent 05e427d commit 99b8a23
Showing 1 changed file with 13 additions and 6 deletions.
Expand Up @@ -132,7 +132,7 @@ public static void main(String[] args) {
if (commandLineArguments.getLogLevel() == Level.DEBUG) {
LOG.error("Unexpected error", e);
} else {
LOG.error(getMessageFromException(e));
LOG.error(getMessagesFromException(e));
}
}
System.exit(1);
Expand Down Expand Up @@ -165,12 +165,19 @@ private static Map<String, String> overrideConfiguration(Map<String, String> exi
}


static String getMessageFromException(Exception e) {
if (e instanceof FlywayException) {
return e.getMessage();
} else {
return e.toString();
static String getMessagesFromException(Throwable e) {
String condensedMessages = "";
String preamble = "";
while (e != null) {
if (e instanceof FlywayException) {
condensedMessages += preamble + e.getMessage();
} else {
condensedMessages += preamble + e.toString();
}
preamble = "\r\nCaused by: ";
e = e.getCause();
}
return condensedMessages;
}


Expand Down

0 comments on commit 99b8a23

Please sign in to comment.