aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-01-23 22:22:30 +0100
committerSven Gothel <[email protected]>2015-01-23 22:22:30 +0100
commit8f29378cfcef86b0e7c351e9c5df3c07b15edca9 (patch)
treec7ea25d13c655f990a41019066a76993ea676062
parent55b9d1a9c22ac2cfba9a876c9860aa3f15199606 (diff)
ExceptionUtils.dumpThrowable(..): Also dump all causes of the given Throwable
-rw-r--r--src/java/com/jogamp/common/ExceptionUtils.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/java/com/jogamp/common/ExceptionUtils.java b/src/java/com/jogamp/common/ExceptionUtils.java
index 7e36880..c848a99 100644
--- a/src/java/com/jogamp/common/ExceptionUtils.java
+++ b/src/java/com/jogamp/common/ExceptionUtils.java
@@ -60,10 +60,19 @@ public class ExceptionUtils {
/**
* Dumps a {@link Throwable} in a decorating message including the current thread name,
* and its {@link #dumpStack(PrintStream, StackTraceElement[], int, int) stack trace}.
+ * <p>
+ * Implementation will iterate through all {@link Throwable#getCause() causes}.
+ * </p>
*/
public static void dumpThrowable(final String additionalDescr, final Throwable t) {
System.err.println("Caught "+additionalDescr+" "+t.getClass().getSimpleName()+": "+t.getMessage()+" on thread "+Thread.currentThread().getName());
dumpStack(System.err, t.getStackTrace(), 0, -1);
+ int causeDepth = 1;
+ for( Throwable cause = t.getCause(); null != cause; cause = cause.getCause() ) {
+ System.err.println("Caused["+causeDepth+"] by "+cause.getClass().getSimpleName()+": "+cause.getMessage()+" on thread "+Thread.currentThread().getName());
+ dumpStack(System.err, cause.getStackTrace(), 0, -1);
+ causeDepth++;
+ }
}
}