28import java.io.PrintStream;
34 public static void dumpStack(
final PrintStream out) {
37 public static void dumpStack(
final PrintStream out,
final int skip,
final int depth) {
38 dumpStack(out,
new Exception(
""), skip+1, depth);
40 public static void dumpStack(
final PrintStream out,
final Throwable t,
final int skip,
final int depth) {
41 dumpStack(out, t.getStackTrace(), skip, depth);
43 public static void dumpStack(
final PrintStream out,
final StackTraceElement[] stack,
final int skip,
final int depth) {
49 maxDepth = stack.length;
51 maxDepth = Math.min(depth+skip, stack.length);
53 for(
int i=skip; i<maxDepth; i++) {
54 out.println(
" ["+i+
"]: "+stack[i]);
72 void printCauseStack(
final PrintStream s,
final String causeStr,
final int causeIdx,
final int stackDepth);
79 void printStackTrace(
final PrintStream s,
final int causeDepth,
final int stackDepth);
92 public static int printCause(
final PrintStream s,
final String causeStr, Throwable cause,
final int causeIdx,
final int causeDepth,
final int stackDepth) {
94 for(;
null != cause && ( -1 == causeDepth || i < causeDepth ); cause = cause.getCause()) {
98 s.println(causeStr+
"["+i+
"] by "+cause.getClass().getSimpleName()+
": "+cause.getMessage()+
" on thread "+Thread.currentThread().getName());
99 dumpStack(s, cause.getStackTrace(), 0, stackDepth);
114 public static void printStackTrace(
final PrintStream s,
final Throwable t,
final int causeDepth,
final int stackDepth) {
118 s.println(t.getClass().getSimpleName()+
": "+t.getMessage()+
" on thread "+Thread.currentThread().getName());
119 dumpStack(s, t.getStackTrace(), 0, stackDepth);
120 printCause(s,
"Caused", t.getCause(), 0, causeDepth, stackDepth);
133 public static void dumpThrowable(
final String additionalDescr,
final Throwable t) {
148 public static void dumpThrowable(
final String additionalDescr,
final Throwable t,
final int causeDepth,
final int stackDepth) {
149 System.err.print(
"Caught "+additionalDescr+
" ");
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 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 dumpStack(final PrintStream out)
static void dumpStack(final PrintStream out, final StackTraceElement[] stack, final int skip, final int depth)
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.
Interface allowing Throwable specializations to provide their custom stack trace presentation.
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!
void printStackTrace(final PrintStream s, final int causeDepth, final int stackDepth)
Custom printStackTrace method, similar to Throwable#printStackTrace(PrintStream, int,...