com.quadrique.jbuildingblocks.core.exception
Class JbbExceptionHandler

java.lang.Object
  extended by com.quadrique.jbuildingblocks.core.exception.JbbExceptionHandler

public class JbbExceptionHandler
extends Object

This class handles linked/chained exceptions


Constructor Summary
JbbExceptionHandler()
          Constructor
 
Method Summary
static JbbExceptionHandler getInstance()
          This method returns an instance of the JbbExceptionHandler class.
 String getMessage(Throwable zException)
          Retrieves the message from the exception or from its predecessor if the top exception is not populated
 String getMessage(Throwable zException, int zStringMaxSize)
          Calls printStackTrace() for all the exceptions in the chain + limit the size of the resulting string to the given number of characters
 Throwable getRootCause(Throwable zException)
           
 String getRootCauseMessage(Throwable zException)
          Retrieves the message from the root cause
 String getRootCauseMessage(Throwable zException, int zMaxSize)
          Retrieves the message from the root cause
 String getStackTrace(Throwable zException)
          Calls printStackTrace() for all the exceptions in the chain
 String getStackTrace(Throwable zException, int zStringMaxSize)
          Calls printStackTrace() for all the exceptions in the chain + limit the size of the resulting string to the given number of characters
 String getSummaryString(JbbException zException)
          Combines the message and stack trace in one string This is ideal for logging an exception on stdout or in a log file
 String getSummaryString(JbbException zException, int zMaxSize)
          Combines the message and stack trace in one string This is ideal for logging an exception on stdout or in a log file
 String getSummaryString(Throwable zException)
          Combines the message and stack trace in one string This is ideal for logging an exception on stdout or in a log file
 String getSummaryString(Throwable zException, int zMaxSize)
          Combines the message and stack trace in one string This is ideal for logging an exception on stdout or in a log file
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JbbExceptionHandler

public JbbExceptionHandler()
Constructor

Method Detail

getInstance

public static final JbbExceptionHandler getInstance()
This method returns an instance of the JbbExceptionHandler class. If there has been already one instantiation, the same instance is returned so that it can be shared across the application. A typical usage would be: JbbExceptionHandler.xxx() or JbbExceptionHandler lHandler = JbbExceptionHandler;

Returns:
the unique JbbExceptionHandler instance

getStackTrace

public String getStackTrace(Throwable zException)
Calls printStackTrace() for all the exceptions in the chain

Parameters:
zException - the exception
Returns:
the stack trace in a string
See Also:
Exception

getStackTrace

public String getStackTrace(Throwable zException,
                            int zStringMaxSize)
Calls printStackTrace() for all the exceptions in the chain + limit the size of the resulting string to the given number of characters

Parameters:
zException - the exception
zStringMaxSize - the max string size (i.e. to limit the size of the exception stack trace)
Returns:
he stack trace in a string
See Also:
Exception

getMessage

public String getMessage(Throwable zException)
Retrieves the message from the exception or from its predecessor if the top exception is not populated

Parameters:
zException - the exception
Returns:
the exception description
See Also:
Exception

getMessage

public String getMessage(Throwable zException,
                         int zStringMaxSize)
Calls printStackTrace() for all the exceptions in the chain + limit the size of the resulting string to the given number of characters

Parameters:
zException - the exception
zStringMaxSize - the max string size (i.e. to limit the size of the exception stack trace)
Returns:
he stack trace in a string
See Also:
Exception

getRootCause

public Throwable getRootCause(Throwable zException)
Parameters:
zException -
Returns:
Throwable object

getRootCauseMessage

public String getRootCauseMessage(Throwable zException)
Retrieves the message from the root cause

Parameters:
zException - the exception
Returns:
the exception description
See Also:
Exception

getRootCauseMessage

public String getRootCauseMessage(Throwable zException,
                                  int zMaxSize)
Retrieves the message from the root cause

Parameters:
zException - the exception
Returns:
the exception description
See Also:
Exception

getSummaryString

public String getSummaryString(Throwable zException)
Combines the message and stack trace in one string This is ideal for logging an exception on stdout or in a log file

Parameters:
zException - the exception
Returns:
the exception summary
See Also:
Exception

getSummaryString

public String getSummaryString(Throwable zException,
                               int zMaxSize)
Combines the message and stack trace in one string This is ideal for logging an exception on stdout or in a log file

Parameters:
zException - the exception
Returns:
the exception summary
See Also:
Exception

getSummaryString

public String getSummaryString(JbbException zException)
Combines the message and stack trace in one string This is ideal for logging an exception on stdout or in a log file

Parameters:
zException - the exception
Returns:
the exception summary
See Also:
Exception

getSummaryString

public String getSummaryString(JbbException zException,
                               int zMaxSize)
Combines the message and stack trace in one string This is ideal for logging an exception on stdout or in a log file

Parameters:
zException - the exception
Returns:
the exception summary
See Also:
Exception


Copyright © 2001-2008 Quadrique Corporation. All Rights Reserved.