Java Utililty Methods Throwable to Root Cause

List of utility methods to do Throwable to Root Cause

Description

The list of methods to do Throwable to Root Cause are organized into topic(s).

Method

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]);
...
StringgetRootCauseStackTrace(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();
StringgetRootStackTrace(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();