/**
* <p>A way to get the entire nested stack-trace of an throwable.</p>
*
* <p>The result of this method is highly dependent on the JDK version
* and whether the exceptions override printStackTrace or not.</p>
*
* @param throwable the <code>Throwable</code> to be examined
* @return the nested stack trace, with the root cause first
* @since 2.0
*/
public static String getFullStackTrace(Throwable throwable) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw, true);
Throwable[] ts = getThrowables(throwable);
for (int i = 0; i < ts.length; i++) {
ts[i].printStackTrace(pw);
if (isNestedThrowable(ts[i])) {
break;
}
}
return sw.getBuffer().toString();
}