From 785af7ed26b18d5c85e40e525859ac65deb37017 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 26 Oct 2014 02:16:31 +0100 Subject: Refine ExceptionUtils: Shorten method name, dumpThrowable uses dumpStack --- src/java/com/jogamp/common/ExceptionUtils.java | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (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 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