List of utility methods to do Throwable to Root Cause
String[] | getRootCauseStackTrace(@Nonnull final Throwable throwable) Yoinked from apache commons 3 because that's what we were using. final Throwable throwables[] = getThrowables(throwable); final int count = throwables.length; final List<String> frames = new ArrayList<>(); List<String> nextTrace = getStackFrameList(throwables[count - 1]); for (int i = count; --i >= 0;) { final List<String> trace = nextTrace; if (i != 0) { nextTrace = getStackFrameList(throwables[i - 1]); ... |
String | getRootCauseStackTrace(Throwable throwable) get Root Cause Stack Trace Throwable rootCause = getRootCause(throwable); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); rootCause.printStackTrace(pw); return sw.toString(); |
String | getRootStackTrace(Throwable t) Gets the root stack trace as a string. StringWriter sw = new StringWriter(); PrintWriter writer = new PrintWriter(sw); getRootCause(t).printStackTrace(writer); return sw.getBuffer().toString(); |