|
ContactCenters V. 0.9.9. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectumontreal.iro.lecuyer.util.ExceptionUtil
public class ExceptionUtil
Provides helper methods to format exceptions in a more compact
way than the default exception formatting.
The default behavior of the Java Virtual Machine when an
uncaught exception occurs is to
call the Throwable.printStackTrace()
method in order to display the full stack trace on the console.
This produces a rather verbose output, especially if
the exception has a cause, i.e., Throwable.getCause()
returns true.
However, for some exception types, e.g., IOException
,
it might be sufficient to display only the exception class name
and message. This can be done by
Throwable.toString()
, but the cause of the
exception is then lost.
This class provides the
throwableToString(Throwable)
which can format and return a short version of the
a throwable's cause chain.
Methods are also provided to install a default
exception handler which calls
throwableToString(Throwable)
instead of Throwable.printStackTrace()
.
Constructor Summary | |
---|---|
ExceptionUtil()
|
Method Summary | |
---|---|
static String |
formatMemoryStatus()
Constructs and returns a string giving memory status of the virtual machine. |
static void |
replaceDefaultExceptionHandler()
Sets the uncaught exception handler to use throwableToString(Throwable) to
print exceptions, i.e., instances of Exception . |
static String |
throwableToString(Throwable throwable)
Converts the throwable throwable to a string, and returns the constructed string. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ExceptionUtil()
Method Detail |
---|
public static String throwableToString(Throwable throwable)
Throwable.toString()
to get a string from the given throwable, and
all its causes.
The formatting is similar to the default
way Java prints exceptions, but
stack trace elements are omitted.
However, if the umontreal.iro.lecuyer.util.PrintStackTrace
property is set to true, the full
stack trace is also formatted for each
throwable.
throwable
- the throwable to convert.
public static void replaceDefaultExceptionHandler()
throwableToString(Throwable)
to
print exceptions, i.e., instances of Exception
.
Other instances of Throwable
, e.g.,
instances of Error
, are printed using
Throwable.printStackTrace()
.
public static String formatMemoryStatus()
|
ContactCenters V. 0.9.9. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |