org.jdiagnose.message
Class ExceptionMessageFactory

java.lang.Object
  extended byorg.jdiagnose.message.ExceptionMessageFactory
All Implemented Interfaces:
MessageFactory

public class ExceptionMessageFactory
extends java.lang.Object
implements MessageFactory

Creates diagnostic messages from exceptions. The exception message is used as the summary and the stacktrace as the body. Will use the root exception by default and can optionally suppress the stack trace. Uses reflection to find the root cause so that it can be backwards compatible with Java 1.3

Author:
jmccrindle

Field Summary
static ExceptionMessageFactory DEFAULT_EXCEPTION_MESSAGE_FACTORY
           
 
Constructor Summary
ExceptionMessageFactory()
          Default Constructor
ExceptionMessageFactory(boolean suppressStackTrace, boolean rootExceptionOnly)
           
 
Method Summary
 DiagnosticMessage getMessage(java.lang.Object object)
           
protected  java.lang.Throwable getRootCause(java.lang.Throwable t)
          Finds the root cause given an exception.
 void setRootExceptionOnly(boolean rootExceptionOnly)
           
 void setSuppressStackTrace(boolean suppressStackTrace)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_EXCEPTION_MESSAGE_FACTORY

public static final ExceptionMessageFactory DEFAULT_EXCEPTION_MESSAGE_FACTORY
Constructor Detail

ExceptionMessageFactory

public ExceptionMessageFactory(boolean suppressStackTrace,
                               boolean rootExceptionOnly)
Parameters:
suppressStackTrace - whether the stackTrace should be used for the message body
rootExceptionOnly - whether the root exception should be used or the whole exception.

ExceptionMessageFactory

public ExceptionMessageFactory()
Default Constructor

Method Detail

getRootCause

protected java.lang.Throwable getRootCause(java.lang.Throwable t)
Finds the root cause given an exception. Uses reflection to make it compatible with Java 1.3

Parameters:
t -
Returns:

getMessage

public DiagnosticMessage getMessage(java.lang.Object object)
Specified by:
getMessage in interface MessageFactory
See Also:
MessageFactory.getMessage(java.lang.Object)

setRootExceptionOnly

public void setRootExceptionOnly(boolean rootExceptionOnly)
Parameters:
rootExceptionOnly - whether the root exception should be used or the whole exception.

setSuppressStackTrace

public void setSuppressStackTrace(boolean suppressStackTrace)
Parameters:
suppressStackTrace - whether the stackTrace should be used for the message body


Copyright © 2004-2005 Grape Design Limited. All Rights Reserved.