summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common/ExceptionUtils.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-10-03 11:44:02 +0200
committerSven Gothel <[email protected]>2015-10-03 11:44:02 +0200
commit026875dd5256051d4e3504f1d9b01f7ce2bb70ff (patch)
treed7d1bd386c870787ffcf737ca6baaeaa6f73ef11 /src/java/com/jogamp/common/ExceptionUtils.java
parent48cef027ec727d3e03b78f577208d1ce10b705d1 (diff)
Bug 1243 - Fix IOUtil.cleanPathString(..) special case ; Allow IOUtil and Uri to handle relative path
Fix IOUtil.cleanPathString(..) special case: Special case '/a/./../b' -> '/b' requires to resolve './' before '../'. Allow IOUtil and Uri to handle relative path: - IOUtil.getParentOf(..) - IOUtil.cleanPathString(..) Handle cases: 'a/./../b' -> 'b' '.././b' -> '../b' - Uri: Handle null scheme
Diffstat (limited to 'src/java/com/jogamp/common/ExceptionUtils.java')
-rw-r--r--src/java/com/jogamp/common/ExceptionUtils.java32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/java/com/jogamp/common/ExceptionUtils.java b/src/java/com/jogamp/common/ExceptionUtils.java
index 108b466..295a59c 100644
--- a/src/java/com/jogamp/common/ExceptionUtils.java
+++ b/src/java/com/jogamp/common/ExceptionUtils.java
@@ -65,26 +65,26 @@ public class ExceptionUtils {
void printStackTrace(final PrintStream s);
}
- public static int dumpCause(final PrintStream s, final String causeStr, Throwable cause, int causeDepth) {
- for( ; null != cause; cause = cause.getCause() ) {
+ public static int dumpCause(final PrintStream s, final String causeStr, Throwable cause, int causeIdx, final int causeDepth, final int stackDepth) {
+ for(int i=0; null != cause && ( -1 == causeDepth || i < causeDepth ); cause = cause.getCause(), i++) {
if( cause instanceof CustomStackTrace ) {
- ((CustomStackTrace)cause).dumpCauseStack(s, causeStr, causeDepth);
+ ((CustomStackTrace)cause).dumpCauseStack(s, causeStr, causeIdx);
} else {
- s.println(causeStr+"["+causeDepth+"] by "+cause.getClass().getSimpleName()+": "+cause.getMessage()+" on thread "+Thread.currentThread().getName());
- dumpStack(s, cause.getStackTrace(), 0, -1);
+ s.println(causeStr+"["+causeIdx+"] by "+cause.getClass().getSimpleName()+": "+cause.getMessage()+" on thread "+Thread.currentThread().getName());
+ dumpStack(s, cause.getStackTrace(), 0, stackDepth);
}
- causeDepth++;
+ causeIdx++;
}
- return causeDepth;
+ return causeIdx;
}
- public static void printStackTrace(final PrintStream s, final Throwable t) {
+ public static void printStackTrace(final PrintStream s, final Throwable t, final int causeDepth, final int stackDepth) {
if( t instanceof CustomStackTrace ) {
((CustomStackTrace)t).printStackTrace(s);
} else {
s.println(t.getClass().getSimpleName()+": "+t.getMessage()+" on thread "+Thread.currentThread().getName());
- dumpStack(s, t.getStackTrace(), 0, -1);
- dumpCause(s, "Caused", t.getCause(), 1);
+ dumpStack(s, t.getStackTrace(), 0, stackDepth);
+ dumpCause(s, "Caused", t.getCause(), 1, causeDepth, stackDepth);
}
}
@@ -96,7 +96,17 @@ public class ExceptionUtils {
* </p>
*/
public static void dumpThrowable(final String additionalDescr, final Throwable t) {
+ dumpThrowable(additionalDescr, t, -1, -1);
+ }
+ /**
+ * 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, final int causeDepth, final int stackDepth) {
System.err.print("Caught "+additionalDescr+" ");
- printStackTrace(System.err, t);
+ printStackTrace(System.err, t, causeDepth, stackDepth);
}
}