net.sf.xframe.ex
Class ExceptionUtil

java.lang.Object
  extended bynet.sf.xframe.ex.ExceptionUtil

public final class ExceptionUtil
extends java.lang.Object

This class provides basic facilities for manipulating exceptions.

Author:
Kurt Riede

Method Summary
static java.lang.String[] captureStackTrace(java.lang.Throwable throwable)
          Captures the stack trace associated with this exception.
static java.lang.Throwable getCause(java.lang.Throwable throwable, boolean useReflection)
          Utility method to get cause of exception.
static java.lang.String printStackTrace(java.lang.Throwable throwable)
          Generate string for specified exception and the cause of this exception (if any).
static java.lang.String printStackTrace(java.lang.Throwable throwable, boolean printCascading)
          Generate string for specified exception and if printCascading is true will print all cascading exceptions.
static java.lang.String printStackTrace(java.lang.Throwable throwable, int depth)
          Serialize the specified Throwable to a string.
static java.lang.String printStackTrace(java.lang.Throwable throwable, int depth, boolean printCascading)
          Generate exception string for specified exception to specified depth and all Cascading exceptions if printCascading is true.
static java.lang.String printStackTrace(java.lang.Throwable throwable, int depth, boolean printCascading, boolean useReflection)
          Generate exception string for specified exception to specified depth and all Cascading exceptions if printCascading is true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

printStackTrace

public static java.lang.String printStackTrace(java.lang.Throwable throwable)
Generate string for specified exception and the cause of this exception (if any).

Parameters:
throwable - a Throwable
Returns:
the stack trace as a String

printStackTrace

public static java.lang.String printStackTrace(java.lang.Throwable throwable,
                                               boolean printCascading)
Generate string for specified exception and if printCascading is true will print all cascading exceptions.

Parameters:
throwable - a Throwable
printCascading - if true will print all cascading exceptions
Returns:
the stack trace as a String

printStackTrace

public static java.lang.String printStackTrace(java.lang.Throwable throwable,
                                               int depth)
Serialize the specified Throwable to a string. Restrict the number of frames printed out to the specified depth. If the depth specified is 0 then all the frames are converted into a string.

Parameters:
throwable - a Throwable
depth - number of stack trace frames to show
Returns:
the stack trace as a String

printStackTrace

public static java.lang.String printStackTrace(java.lang.Throwable throwable,
                                               int depth,
                                               boolean printCascading)
Generate exception string for specified exception to specified depth and all Cascading exceptions if printCascading is true.

Parameters:
throwable - a Throwable
depth - number of stack trace frames to show
printCascading - if true will print all cascading exceptions
Returns:
the stack trace as a String

printStackTrace

public static java.lang.String printStackTrace(java.lang.Throwable throwable,
                                               int depth,
                                               boolean printCascading,
                                               boolean useReflection)
Generate exception string for specified exception to specified depth and all Cascading exceptions if printCascading is true. If useReflection is true then the method will also attempt to use reflection to find a method with signature Throwable getCause(). This makes it compatible with JDK1.4 mechanisms for nesting exceptions.

Parameters:
throwable - a Throwable
depth - number of stack trace frames to show
printCascading - if true will print all cascading exceptions
useReflection - if true will use reflection to handle JDK1.4 nested exceptions
Returns:
the stack trace as a String

getCause

public static java.lang.Throwable getCause(java.lang.Throwable throwable,
                                           boolean useReflection)
Utility method to get cause of exception.

Parameters:
throwable - a Throwable
useReflection - if true will use reflection to handle JDK1.4 nested exceptions
Returns:
cause of specified exception

captureStackTrace

public static java.lang.String[] captureStackTrace(java.lang.Throwable throwable)
Captures the stack trace associated with this exception.

Parameters:
throwable - a Throwable
Returns:
an array of Strings describing stack frames.


Copyright © 2004-2005 xframe. All Rights Reserved.