Package com.xmlmind.util
Class ThrowableUtil
- java.lang.Object
-
- com.xmlmind.util.ThrowableUtil
-
public final class ThrowableUtil extends Object
A collection of utility functions (static methods) related to Exceptions.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
detailedReason(Throwable e)
Equivalent todetailedReason(e, 1)
.static String
detailedReason(Throwable e, int maxCauses)
Same asreason(java.lang.Throwable)
except that the stack trace of specified exception is integrated to returned message.static void
detailedReason(Throwable e, StringBuilder buffer)
Copies both the message and the stack trace of specified exception to specified buffer.static String
reason(Throwable e)
Returns the message of specified exception.static String
reasonLine(Throwable e)
One line describing specified Throwable in a comprehensive way.
-
-
-
Method Detail
-
reason
public static String reason(Throwable e)
Returns the message of specified exception. Returns the class name of specified exception if this exception has no message.
-
reasonLine
public static String reasonLine(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 String detailedReason(Throwable e)
Equivalent todetailedReason(e, 1)
.
-
detailedReason
public static String detailedReason(Throwable e, int maxCauses)
Same asreason(java.lang.Throwable)
except that the stack trace of specified exception is integrated to returned message.- Parameters:
e
- the Throwable to be formattedmaxCauses
- 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(Throwable e, StringBuilder buffer)
Copies both the message and the stack trace of specified exception to specified buffer.
-
-