diff options
author | Sven Gothel <[email protected]> | 2014-10-26 02:16:31 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-10-26 02:16:31 +0100 |
commit | 785af7ed26b18d5c85e40e525859ac65deb37017 (patch) | |
tree | 8e6c0e91f70ee57fdf208725662327c71954cd26 /src/java/com/jogamp/common/ExceptionUtils.java | |
parent | 6f5b67d998b1be9b49584bbb55814d10fe55e813 (diff) |
Refine ExceptionUtils: Shorten method name, dumpThrowable uses dumpStack
Diffstat (limited to 'src/java/com/jogamp/common/ExceptionUtils.java')
-rw-r--r-- | src/java/com/jogamp/common/ExceptionUtils.java | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/java/com/jogamp/common/ExceptionUtils.java b/src/java/com/jogamp/common/ExceptionUtils.java index 5829298..598cc61 100644 --- a/src/java/com/jogamp/common/ExceptionUtils.java +++ b/src/java/com/jogamp/common/ExceptionUtils.java @@ -33,28 +33,37 @@ import java.io.PrintStream; * @since 2.3.0 */ public class ExceptionUtils { - public static void dumpStackTrace(final PrintStream out, final int skip, final int depth) { - dumpStackTrace(out, new Exception(""), skip+1, depth); + public static void dumpStack(final PrintStream out) { + dumpStack(out, 0, -1); } - public static void dumpStackTrace(final PrintStream out, final Throwable t, final int skip, final int depth) { - dumpStackTrace(out, t.getStackTrace(), skip, depth); + public static void dumpStack(final PrintStream out, final int skip, final int depth) { + dumpStack(out, new Exception(""), skip+1, depth); } - public static void dumpStackTrace(final PrintStream out, final StackTraceElement[] stack, final int skip, final int depth) { + public static void dumpStack(final PrintStream out, final Throwable t, final int skip, final int depth) { + dumpStack(out, t.getStackTrace(), skip, depth); + } + public static void dumpStack(final PrintStream out, final StackTraceElement[] stack, final int skip, final int depth) { if( null == stack ) { return; } - final int maxDepth = Math.min(depth+skip, stack.length); + final int maxDepth; + if( 0 > depth ) { + maxDepth = stack.length; + } else { + maxDepth = Math.min(depth+skip, stack.length); + } for(int i=skip; i<maxDepth; i++) { out.println(" ["+i+"]: "+stack[i]); } } /** - * Dumps a Throwable in a decorating message including the current thread name, and stack trace. + * Dumps a {@link Throwable} in a decorating message including the current thread name, + * and its {@link #dumpStack(PrintStream, StackTraceElement[], int, int) stack trace}. */ 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()); - t.printStackTrace(); + dumpStack(System.err, t.getStackTrace(), 0, -1); } } |