gov.usda.gdpc.util
Class ExceptionUtils

java.lang.Object
  extended bygov.usda.gdpc.util.ExceptionUtils

public final class ExceptionUtils
extends java.lang.Object

Author:
terryc

Field Summary
static int DEFAULT_MAX_NUMBER_ENTRIES
          Default maximun number of entries.
 
Method Summary
static java.lang.String getExceptionCauses(java.lang.Throwable exception)
          This gets an exception's cause history.
static java.lang.String getExceptionCausesWithClassNames(java.lang.Throwable exception)
          This gets an exception's cause history.
static java.lang.String getStackTrace(java.lang.Exception exception, int max)
          This sends an exception's stack trace to the specified logger.
static void logExceptionCauses(java.lang.Throwable exception, org.apache.log4j.Logger logger, org.apache.log4j.Priority priorty)
          This sends an exception's cause history to the specified logger.
static void logStackTrace(java.lang.Exception exception, int max, org.apache.log4j.Logger logger, org.apache.log4j.Priority priorty)
          This sends an exception's stack trace to the specified logger.
static void logStackTrace(java.lang.Exception exception, org.apache.log4j.Logger logger)
          This sends an exception's stack trace to the specified logger.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAX_NUMBER_ENTRIES

public static final int DEFAULT_MAX_NUMBER_ENTRIES
Default maximun number of entries.

See Also:
Constant Field Values
Method Detail

logStackTrace

public static void logStackTrace(java.lang.Exception exception,
                                 org.apache.log4j.Logger logger)
This sends an exception's stack trace to the specified logger. The max parameter defines the maximun number of entries to send to the logger. This logs the default number of entries defined by DEFAULT_MAX_NUMBER_ENTRIES at the default priorty of debug.

Parameters:
exception - exception to log
logger - logger to send entries

logStackTrace

public static void logStackTrace(java.lang.Exception exception,
                                 int max,
                                 org.apache.log4j.Logger logger,
                                 org.apache.log4j.Priority priorty)
This sends an exception's stack trace to the specified logger. The max parameter defines the maximun number of entries to send to the logger. Setting max to a negative number sends all the entries in the stack track to the logger.

Parameters:
exception - exception to log
max - maximun number of entries to log
logger - logger to send entries
priorty - priorty of log message

getStackTrace

public static java.lang.String getStackTrace(java.lang.Exception exception,
                                             int max)
This sends an exception's stack trace to the specified logger. The max parameter defines the maximun number of entries to send to the logger. Setting max to a negative number sends all the entries in the stack track to the logger.

Parameters:
exception - exception to log
max - maximun number of entries to log
Returns:
stack trace as string

logExceptionCauses

public static void logExceptionCauses(java.lang.Throwable exception,
                                      org.apache.log4j.Logger logger,
                                      org.apache.log4j.Priority priorty)
This sends an exception's cause history to the specified logger.

Parameters:
exception - exception to log
logger - logger to send entries
priorty - priorty of log message

getExceptionCauses

public static java.lang.String getExceptionCauses(java.lang.Throwable exception)
This gets an exception's cause history. Only the message text is included (e.g. the exception's class names are not output).

Parameters:
exception - exception to log
Returns:
exception's cause history as a string

getExceptionCausesWithClassNames

public static java.lang.String getExceptionCausesWithClassNames(java.lang.Throwable exception)
This gets an exception's cause history.

Parameters:
exception - exception to log
Returns:
exception's cause history as a string