* @param e - the exception received
*/
public static void sendClientError(MessageBus bus, Message message, String errorMessage, Throwable e) {
if (e != null) {
StringAppender a = new StringAppender("<br/>").append(e.getClass().getName() + ": " + e.getMessage()).append("<br/>");
// Let's build-up the stacktrace.
boolean first = true;
for (StackTraceElement sel : e.getStackTrace()) {
a.append(first ? "" : " ").append(sel.toString()).append("<br/>");
first = false;
}
// And add the entire causal chain.
while ((e = e.getCause()) != null) {
first = true;
a.append("Caused by:<br/>");
for (StackTraceElement sel : e.getStackTrace()) {
a.append(first ? "" : " ").append(sel.toString()).append("<br/>");
first = false;
}
}
sendClientError(bus, message, errorMessage, a.toString());
}
else {
sendClientError(bus, message, errorMessage, "No additional details.");
}