Project Wonder 5.0

er.extensions.foundation
Class ERXExceptionUtilities

java.lang.Object
  extended by er.extensions.foundation.ERXExceptionUtilities

public class ERXExceptionUtilities
extends java.lang.Object

Provides a set of utilities for displaying and managing exceptions.

Author:
mschrag

Nested Class Summary
static class ERXExceptionUtilities.HideStackTraceException
          Wraps a root cause, but does not render a stack trace to the given writer.
static interface ERXExceptionUtilities.WeDontNeedAStackTraceException
          Implemented by any exception that you explicitly want to not appear in stack dumps.
 
Field Summary
static org.apache.log4j.Logger log
           
 
Constructor Summary
ERXExceptionUtilities()
           
 
Method Summary
protected static void _printSingleStackTrace(java.lang.Throwable t, java.io.PrintWriter writer, int exceptionDepth, boolean cleanupStackTrace)
           
protected static java.lang.Throwable getCause(java.lang.Throwable t)
          Returns the cause of an exception.
static java.lang.Throwable getMeaningfulThrowable(java.lang.Throwable t)
          Returns the "meaningful" root cause from a throwable.
static void logStackTrace()
          Logs a debug stack trace.
static void printStackTrace()
          Prints a debug stack trace to the console.
static void printStackTrace(java.lang.Throwable t)
          Prints the given throwable to the console (stdout).
static void printStackTrace(java.lang.Throwable t, java.io.OutputStream os)
          Prints the given throwable to the given outputstream.
static void printStackTrace(java.lang.Throwable t, java.io.PrintWriter writer)
          Prints the given throwable to the given printwriter.
static void printStackTrace(java.lang.Throwable t, java.io.PrintWriter writer, int exceptionDepth)
          Prints the given throwable to the given writer with an indent.
static void printStackTrace(java.lang.Throwable t, java.io.Writer writer)
          Prints the given throwable to the given printwriter.
static java.lang.String toParagraph(java.lang.Throwable t)
          Returns a paragraph form of the given throwable.
static java.lang.String toParagraph(java.lang.Throwable t, boolean removeHtmlTags)
          Returns a paragraph form of the given throwable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static final org.apache.log4j.Logger log
Constructor Detail

ERXExceptionUtilities

public ERXExceptionUtilities()
Method Detail

getCause

protected static java.lang.Throwable getCause(java.lang.Throwable t)
Returns the cause of an exception. This should be modified to be pluggable.

Parameters:
t - the original exception
Returns:
the cause of the exception or null of there isn't one

toParagraph

public static java.lang.String toParagraph(java.lang.Throwable t)
Returns a paragraph form of the given throwable.

Parameters:
t - the throwable to convert to paragraph form
Returns:
the paragraph string

toParagraph

public static java.lang.String toParagraph(java.lang.Throwable t,
                                           boolean removeHtmlTags)
Returns a paragraph form of the given throwable.

Parameters:
t - the throwable to convert to paragraph form
removeHtmlTags - if true, html tags will be filtered from the error messages (to remove, for instance, bold tags from validation messages)
Returns:
the paragraph string

getMeaningfulThrowable

public static java.lang.Throwable getMeaningfulThrowable(java.lang.Throwable t)
Returns the "meaningful" root cause from a throwable. For instance, an InvocationTargetException is useless -- it's the cause that matters.

Parameters:
t - the meaningful exception given another throwable
Returns:
the meaningful exception

printStackTrace

public static void printStackTrace()
Prints a debug stack trace to the console.


logStackTrace

public static void logStackTrace()
Logs a debug stack trace.


printStackTrace

public static void printStackTrace(java.lang.Throwable t)
Prints the given throwable to the console (stdout).

Parameters:
t - the throwable to print

printStackTrace

public static void printStackTrace(java.lang.Throwable t,
                                   java.io.OutputStream os)
Prints the given throwable to the given outputstream.

Parameters:
t - the throwable to print
os - the stream to print to

printStackTrace

public static void printStackTrace(java.lang.Throwable t,
                                   java.io.Writer writer)
Prints the given throwable to the given printwriter.

Parameters:
t - the throwable to print
writer - the writer to print to

printStackTrace

public static void printStackTrace(java.lang.Throwable t,
                                   java.io.PrintWriter writer)
Prints the given throwable to the given printwriter.

Parameters:
t - the throwable to print
writer - the writer to print to

_printSingleStackTrace

protected static void _printSingleStackTrace(java.lang.Throwable t,
                                             java.io.PrintWriter writer,
                                             int exceptionDepth,
                                             boolean cleanupStackTrace)

printStackTrace

public static void printStackTrace(java.lang.Throwable t,
                                   java.io.PrintWriter writer,
                                   int exceptionDepth)
Prints the given throwable to the given writer with an indent.

Parameters:
t - the throwable to print
writer - the writer to print to
exceptionDepth - the indent level to use
Properties
er.extensions.stackTrace.cleanup if true, stack traces are cleaned up for easier use
           
er.extensions.stackTrace.skipPatternsFile the name the resource that contains an array of class name and method regexes to skip in stack traces
           

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.