Here you can find the source of deeplyPrint(Throwable e, PrintStream strm, boolean stackTrace)
public static void deeplyPrint(Throwable e, PrintStream strm, boolean stackTrace)
//package com.java2s; /******************************************************************************* * Copyright (c) 2004, 2006//from w w w. j a va2 s . c o m * Thomas Hallgren, Kenneth Olwing, Mitch Sonies * Pontus Rydin, Nils Unden, Peer Torngren * The code, documentation and other materials contained herein have been * licensed under the Eclipse Public License - v 1.0 by the individual * copyright holders listed above, as Initial Contributors under such license. * The text of such license is available at www.eclipse.org. *******************************************************************************/ import java.io.PrintStream; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; public class Main { public static void deeplyPrint(Throwable e, PrintStream strm, boolean stackTrace) { deeplyPrint(e, strm, stackTrace, 0); } private static void deeplyPrint(CoreException ce, PrintStream strm, boolean stackTrace, int level) { appendLevelString(strm, level); if (stackTrace) ce.printStackTrace(strm); deeplyPrint(ce.getStatus(), strm, stackTrace, level); } private static void deeplyPrint(IStatus status, PrintStream strm, boolean stackTrace, int level) { appendLevelString(strm, level); String msg = status.getMessage(); strm.println(msg); Throwable cause = status.getException(); if (cause != null) { strm.print("Caused by: "); //$NON-NLS-1$ if (stackTrace || !(msg.equals(cause.getMessage()) || msg.equals(cause.toString()))) deeplyPrint(cause, strm, stackTrace, level); } if (status.isMultiStatus()) { IStatus[] children = status.getChildren(); for (int i = 0; i < children.length; i++) deeplyPrint(children[i], strm, stackTrace, level + 1); } } private static void deeplyPrint(Throwable t, PrintStream strm, boolean stackTrace, int level) { if (t instanceof CoreException) deeplyPrint((CoreException) t, strm, stackTrace, level); else { appendLevelString(strm, level); if (stackTrace) t.printStackTrace(strm); else { strm.println(t.toString()); Throwable cause = t.getCause(); if (cause != null) { strm.print("Caused by: "); //$NON-NLS-1$ deeplyPrint(cause, strm, stackTrace, level); } } } } private static void appendLevelString(PrintStream strm, int level) { if (level > 0) { strm.print("[0"); //$NON-NLS-1$ for (int idx = 1; idx < level; ++idx) { strm.print('.'); strm.print(level); } strm.print(']'); } } }