From 8f29378cfcef86b0e7c351e9c5df3c07b15edca9 Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Fri, 23 Jan 2015 22:22:30 +0100
Subject: ExceptionUtils.dumpThrowable(..): Also dump all causes of the given
 Throwable

---
 src/java/com/jogamp/common/ExceptionUtils.java | 9 +++++++++
 1 file changed, 9 insertions(+)

(limited to 'src/java/com/jogamp/common/ExceptionUtils.java')

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++;
+        }
     }
 
 }
-- 
cgit v1.2.3