Skip to content

Commit

Permalink
#1142 detailed error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Aug 22, 2022
1 parent 7a4160a commit 0d9bfa0
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/main/java/org/takes/facets/fallback/TkFallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,31 @@ private static Throwable error(final Throwable exp, final Request req,
"[%s %s] failed in %s: %s",
new RqMethod.Base(req).method(),
new RqHref.Base(req).href(),
time, exp.getLocalizedMessage()
time, TkFallback.msg(exp)
),
exp
);
}

/**
* Get full error message from the exception and all its kids.
* @param exp Exception original
* @return Error message
*/
private static String msg(final Throwable exp) {
final StringBuilder txt = new StringBuilder(0);
final String localized = exp.getLocalizedMessage();
if (localized == null) {
txt.append("NULL");
} else {
txt.append(localized);
}
final Throwable cause = exp.getCause();
if (cause != null) {
txt.append("; ");
txt.append(TkFallback.msg(cause));
}
return txt.toString();
}

}

0 comments on commit 0d9bfa0

Please sign in to comment.