List of utility methods to do Exception Message
Exception | exception(Throwable e) exception if (e instanceof Exception) { return (Exception) e; } else { return new Exception(e); |
String | exception(Throwable t) Constructs a pretty one line version of a Throwable . StackTraceElement[] trace = t.getStackTrace(); return t.getClass().getSimpleName() + " : " + t.getMessage() + ((trace.length > 0) ? " @ " + t.getStackTrace()[0].getClassName() + ":" + t.getStackTrace()[0].getLineNumber() : ""); |
String | exceptionMessage(Object... strings) exception Message StringBuilder msg = new StringBuilder(); msg.append(strings[0]).append(System.lineSeparator()); msg.append("Additional exception info:").append(System.lineSeparator()); for (int i = 1; i < strings.length; i++) { msg.append("\t").append(strings[i]).append(System.lineSeparator()); msg.append("Stacktrace:"); return msg.toString(); ... |
String | exceptionMessage(Throwable e) exception Message StringBuilder buffer = new StringBuilder(); buffer.append(extractMessage(e)); if (e.getCause() != null) { buffer.append(" [cause: ").append(extractMessage(e.getCause())).append("]"); return buffer.toString(); |
String | exceptionSimpleDesc(final Exception e) exception Simple Desc StringBuffer sb = new StringBuffer(); if (e != null) { sb.append(e.toString()); StackTraceElement[] stackTrace = e.getStackTrace(); if (stackTrace != null && stackTrace.length > 0) { StackTraceElement elment = stackTrace[0]; sb.append(", "); sb.append(elment.toString()); ... |
String | exceptionStackTrace(Exception ex) exception Stack Trace StringBuffer buffer = new StringBuffer(); for (StackTraceElement element : ex.getStackTrace()) { buffer.append(element.toString()); buffer.append("\n"); return buffer.toString(); |