com.taursys.util
Class ChainedException

java.lang.Object
  extended byjava.lang.Throwable
      extended byjava.lang.Exception
          extended bycom.taursys.util.ChainedException
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ModelException, RecycleException, RenderException

public class ChainedException
extends java.lang.Exception

A ChainedException is a subclass of Exception which contains a Throwable cause. This allows for the creation of a single linked list of exceptions and their respective causes. The printStackTrace() methods display the trace for this exception and then invoke the method for the cause (which can in turn invoke a trace for its ancestory).

The ChainedException also provides for diagnostic information. This information will be displayed in the stack trace, but not included in the basic message. The diagnostic information is available through the getLocalizedMessage method.

See Also:
Serialized Form

Field Summary
protected  java.lang.Throwable cause
           
protected  java.lang.String diagnosticInfo
           
protected  int reason
           
static int REASON_INVALID_REASON_CODE
           
static int REASON_UNSPECIFIED
           
protected  java.lang.String userFriendlyMessage
           
 
Constructor Summary
  ChainedException(int reason)
          Creates a ModelException with a reason code.
  ChainedException(int reason, java.lang.String diagnosticInfo)
          Creates a ModelException with a reason code and diagnostic information.
  ChainedException(int reason, java.lang.Throwable cause)
          Creates a ModelException with a reason code and cause.
  ChainedException(int reason, java.lang.Throwable cause, java.lang.String diagnosticInfo)
          Creates a ModelException with a reason code, cause and diagnostic information.
protected ChainedException(java.lang.String message)
          Creates a ChainedException with a message.
protected ChainedException(java.lang.String message, int reason)
          Creates a ChainedException with a message.
protected ChainedException(java.lang.String message, int reason, java.lang.Throwable cause)
          Creates a ChainedException with a message.
 
Method Summary
 java.lang.Throwable getCause()
          Accesses the original cause of this ChainedException.
 java.lang.String getDiagnosticInfo()
          Returns the current diagnostic information.
static java.lang.String getInvalidMessage()
          Returns String for given reason code else String for REASON_INVALID_REASON_CODE.
 java.lang.String getLocalizedMessage()
          Override of superclass method to provide diagnostic information (if exists).
 int getReason()
          Returns the reason code.
static java.lang.String getReasonMessage(int reason)
          Returns String for given reason code else String for REASON_INVALID_REASON_CODE.
 java.lang.String getUserFriendlyMessage()
          Returns the current userFriendlyMessage.
static void main(java.lang.String[] args)
          Main for designing/viewing
 void printStackTrace()
          Prints this ChainedException and its cause to the standard error stream.
 void printStackTrace(java.io.PrintStream printStream)
          Prints this ChainedException and its cause to the given print stream.
 void printStackTrace(java.io.PrintWriter printWriter)
          Prints this ChainedException and its cause to the given print writer.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getMessage, getStackTrace, initCause, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

REASON_INVALID_REASON_CODE

public static final int REASON_INVALID_REASON_CODE
See Also:
Constant Field Values

REASON_UNSPECIFIED

public static final int REASON_UNSPECIFIED
See Also:
Constant Field Values

cause

protected java.lang.Throwable cause

diagnosticInfo

protected java.lang.String diagnosticInfo

reason

protected int reason

userFriendlyMessage

protected java.lang.String userFriendlyMessage
Constructor Detail

ChainedException

public ChainedException(int reason)
Creates a ModelException with a reason code. The reason code will also be used to set the message.


ChainedException

public ChainedException(int reason,
                        java.lang.Throwable cause)
Creates a ModelException with a reason code and cause. The reason code will also be used to set the message.


ChainedException

public ChainedException(int reason,
                        java.lang.Throwable cause,
                        java.lang.String diagnosticInfo)
Creates a ModelException with a reason code, cause and diagnostic information. The reason code will also be used to set the message.


ChainedException

public ChainedException(int reason,
                        java.lang.String diagnosticInfo)
Creates a ModelException with a reason code and diagnostic information. The reason code will also be used to set the message.


ChainedException

protected ChainedException(java.lang.String message)
Creates a ChainedException with a message. This constructor is only available to subclasses.


ChainedException

protected ChainedException(java.lang.String message,
                           int reason)
Creates a ChainedException with a message. This constructor is only available to subclasses. This constructor does not alter the message. It simply stores the message and reason.


ChainedException

protected ChainedException(java.lang.String message,
                           int reason,
                           java.lang.Throwable cause)
Creates a ChainedException with a message. This constructor is only available to subclasses. This constructor appends the cause message to given message separated by a ": ". It then stores the message, reason code and cause.

Method Detail

getReasonMessage

public static java.lang.String getReasonMessage(int reason)
Returns String for given reason code else String for REASON_INVALID_REASON_CODE.


getInvalidMessage

public static java.lang.String getInvalidMessage()
Returns String for given reason code else String for REASON_INVALID_REASON_CODE.


getReason

public int getReason()
Returns the reason code.


getCause

public java.lang.Throwable getCause()
Accesses the original cause of this ChainedException.


getUserFriendlyMessage

public java.lang.String getUserFriendlyMessage()
Returns the current userFriendlyMessage.


getLocalizedMessage

public java.lang.String getLocalizedMessage()
Override of superclass method to provide diagnostic information (if exists). Provides original message plus diagnostic information.


getDiagnosticInfo

public java.lang.String getDiagnosticInfo()
Returns the current diagnostic information.


printStackTrace

public void printStackTrace()
Prints this ChainedException and its cause to the standard error stream.


printStackTrace

public void printStackTrace(java.io.PrintStream printStream)
Prints this ChainedException and its cause to the given print stream.


printStackTrace

public void printStackTrace(java.io.PrintWriter printWriter)
Prints this ChainedException and its cause to the given print writer.


main

public static void main(java.lang.String[] args)
Main for designing/viewing



Copyright © 2007 Martin T Phelan. All Rights Reserved.