28package com.jogamp.common;
30import java.io.PrintStream;
36 public static void dumpStack(
final PrintStream out) {
39 public static void dumpStack(
final PrintStream out,
final int skip,
final int depth) {
40 dumpStack(out,
new Exception(
""), skip+1, depth);
42 public static void dumpStack(
final PrintStream out,
final Throwable t,
final int skip,
final int depth) {
43 dumpStack(out, t.getStackTrace(), skip, depth);
45 public static void dumpStack(
final PrintStream out,
final StackTraceElement[] stack,
final int skip,
final int depth) {
51 maxDepth = stack.length;
53 maxDepth = Math.min(depth+skip, stack.length);
55 for(
int i=skip; i<maxDepth; i++) {
56 out.println(
" ["+i+
"]: "+stack[i]);
74 void printCauseStack(
final PrintStream s,
final String causeStr,
final int causeIdx,
final int stackDepth);
81 void printStackTrace(
final PrintStream s,
final int causeDepth,
final int stackDepth);
94 public static int printCause(
final PrintStream s,
final String causeStr, Throwable cause,
final int causeIdx,
final int causeDepth,
final int stackDepth) {
96 for(;
null != cause && ( -1 == causeDepth || i < causeDepth ); cause = cause.getCause()) {
100 s.println(causeStr+
"["+i+
"] by "+cause.getClass().getSimpleName()+
": "+cause.getMessage()+
" on thread "+Thread.currentThread().getName());
101 dumpStack(s, cause.getStackTrace(), 0, stackDepth);
116 public static void printStackTrace(
final PrintStream s,
final Throwable t,
final int causeDepth,
final int stackDepth) {
120 s.println(t.getClass().getSimpleName()+
": "+t.getMessage()+
" on thread "+Thread.currentThread().getName());
121 dumpStack(s, t.getStackTrace(), 0, stackDepth);
122 printCause(s,
"Caused", t.getCause(), 0, causeDepth, stackDepth);
135 public static void dumpThrowable(
final String additionalDescr,
final Throwable t) {
150 public static void dumpThrowable(
final String additionalDescr,
final Throwable t,
final int causeDepth,
final int stackDepth) {
151 System.err.print(
"Caught "+additionalDescr+
" ");
static void dumpStack(final PrintStream out, final StackTraceElement[] stack, final int skip, final int depth)
static void dumpStack(final PrintStream out, final int skip, final int depth)
static int printCause(final PrintStream s, final String causeStr, Throwable cause, final int causeIdx, final int causeDepth, final int stackDepth)
Prints the given Throwable cause to the output PrintStream s.
static void dumpThrowable(final String additionalDescr, final Throwable t, final int causeDepth, final int stackDepth)
Dumps a Throwable to System.err in a decorating message including the current thread name,...
static void dumpThrowable(final String additionalDescr, final Throwable t)
Dumps a Throwable to System.err in a decorating message including the current thread name,...
static void dumpStack(final PrintStream out, final Throwable t, final int skip, final int depth)
static void printStackTrace(final PrintStream s, final Throwable t, final int causeDepth, final int stackDepth)
Prints the given Throwable to the output PrintStream s.
static void dumpStack(final PrintStream out)
Interface allowing Throwable specializations to provide their custom stack trace presentation.
void printStackTrace(final PrintStream s, final int causeDepth, final int stackDepth)
Custom printStackTrace method, similar to Throwable#printStackTrace(PrintStream, int,...
void printCauseStack(final PrintStream s, final String causeStr, final int causeIdx, final int stackDepth)
Prints this Throwable as a cause to the output PrintStream s, not iterating over all inner causes!