com.xmlmind.util
Class ThrowableUtil

java.lang.Object
  extended by com.xmlmind.util.ThrowableUtil

public final class ThrowableUtil
extends java.lang.Object

A collection of utility functions (static methods) related to Exceptions.


Method Summary
static java.lang.String detailedReason(java.lang.Throwable e)
          Equivalent to detailedReason(e, 1).
static java.lang.String detailedReason(java.lang.Throwable e, int maxCauses)
          Same as reason(java.lang.Throwable) except that the stack trace of specified exception is integrated to returned message.
static void detailedReason(java.lang.Throwable e, java.lang.StringBuilder buffer)
          Copies both the message and the stack trace of specified exception to specified buffer.
static java.lang.String reason(java.lang.Throwable e)
          Returns the message of specified exception.
static java.lang.String reasonLine(java.lang.Throwable e)
          One line describing specified Throwable in a comprehensive way.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

reason

public static java.lang.String reason(java.lang.Throwable e)
Returns the message of specified exception. Returns the class name of specified exception if this exception has no message.


reasonLine

public static java.lang.String reasonLine(java.lang.Throwable e)
One line describing specified Throwable in a comprehensive way.

More detailed than (single-line) reason(java.lang.Throwable) and less detailed than (multi-line) detailedReason(java.lang.Throwable).


detailedReason

public static java.lang.String detailedReason(java.lang.Throwable e)
Equivalent to detailedReason(e, 1).


detailedReason

public static java.lang.String detailedReason(java.lang.Throwable e,
                                              int maxCauses)
Same as reason(java.lang.Throwable) except that the stack trace of specified exception is integrated to returned message.

Parameters:
e - the Throwable to be formatted
maxCauses - in case of a chained Throwable, maximum number of causes (Throwable.getCause()) to be included in the formatted string
Returns:
formatted string representation of specified Throwable

detailedReason

public static void detailedReason(java.lang.Throwable e,
                                  java.lang.StringBuilder buffer)
Copies both the message and the stack trace of specified exception to specified buffer.