org.wegra.lang
Class ChainedException

java.lang.Object
  extended byjava.lang.Throwable
      extended byjava.lang.Exception
          extended byorg.wegra.lang.ChainedException
All Implemented Interfaces:
java.io.Serializable

public class ChainedException
extends java.lang.Exception

See Also:
Serialized Form

Constructor Summary
ChainedException()
          Constructs a new throwable with null as its detail message.
ChainedException(java.lang.String message)
          Constructs a new throwable with the specified detail message.
ChainedException(java.lang.String message, java.lang.Throwable cause)
          Constructs a new throwable with the specified detail message and cause.
ChainedException(java.lang.Throwable cause)
          Constructs a new throwable with the specified cause and a detail message of (cause==null ?
 
Method Summary
 java.lang.Throwable getCause()
          Returns the cause of this throwable or null if the cause is nonexistent or unknown.
 java.lang.Throwable initCause(java.lang.Throwable cause)
          Initializes the cause of this throwable to the specified value.
 void printStackTrace(java.io.PrintStream stream)
          Prints this throwable and its backtrace to the specified print stream.
 void printStackTrace(java.io.PrintWriter writer)
          Prints this throwable and its backtrace to the specified print writer.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ChainedException

public ChainedException()
Constructs a new throwable with null as its detail message. The cause is not initialized, and may subsequently be initialized by a call to initCause(java.lang.Throwable).

The Throwable.fillInStackTrace() method is called to initialize the stack trace data in the newly created throwable.


ChainedException

public ChainedException(java.lang.String message)
Constructs a new throwable with the specified detail message. The cause is not initialized, and may subsequently be initialized by a call to initCause(java.lang.Throwable).

The Throwable.fillInStackTrace() method is called to initialize the stack trace data in the newly created throwable.

Parameters:
message - the detail message. The detail message is saved for later retrieval by the Throwable.getMessage() method.

ChainedException

public ChainedException(java.lang.String message,
                        java.lang.Throwable cause)
Constructs a new throwable with the specified detail message and cause.

Note that the detail message associated with cause is not automatically incorporated in this throwable's detail message.

The Throwable.fillInStackTrace() method is called to initialize the stack trace data in the newly created throwable.

Parameters:
message - the detail message (which is saved for later retrieval by the Throwable.getMessage() method).
cause - the cause (which is saved for later retrieval by the getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)

ChainedException

public ChainedException(java.lang.Throwable cause)
Constructs a new throwable with the specified cause and a detail message of (cause==null ? null : cause.toString()) (which typically contains the class and detail message of cause). This constructor is useful for throwables that are little more than wrappers for other throwables (for example, java.security.PrivilegedActionException).

The Throwable.fillInStackTrace() method is called to initialize the stack trace data in the newly created throwable.

Parameters:
cause - the cause (which is saved for later retrieval by the getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
Method Detail

getCause

public java.lang.Throwable getCause()
Returns the cause of this throwable or null if the cause is nonexistent or unknown. (The cause is the throwable that caused this throwable to get thrown.)

This implementation returns the cause that was supplied via one of the constructors requiring a Throwable, or that was set after creation with the initCause(Throwable) method. While it is typically unnecessary to override this method, a subclass can override it to return a cause set by some other means. This is appropriate for a "legacy chained throwable" that predates the addition of chained exceptions to Throwable. Note that it is not necessary to override any of the PrintStackTrace methods, all of which invoke the getCause method to determine the cause of a throwable.

Returns:
the cause of this throwable or null if the cause is nonexistent or unknown.

initCause

public java.lang.Throwable initCause(java.lang.Throwable cause)
Initializes the cause of this throwable to the specified value. (The cause is the throwable that caused this throwable to get thrown.)

This method can be called at most once. It is generally called from within the constructor, or immediately after creating the throwable. If this throwable was created with Throwable(Throwable) or Throwable(String,Throwable), this method cannot be called even once.

Parameters:
cause - the cause (which is saved for later retrieval by the getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
Returns:
a reference to this Throwable instance.
Throws:
java.lang.IllegalArgumentException - if cause is this throwable. (A throwable cannot be its own cause.)
java.lang.IllegalStateException - if this throwable was created with Throwable(Throwable) or Throwable(String,Throwable), or this method has already been called on this throwable.

printStackTrace

public void printStackTrace(java.io.PrintStream stream)
Prints this throwable and its backtrace to the specified print stream.

Parameters:
stream - PrintWriter to use for output

printStackTrace

public void printStackTrace(java.io.PrintWriter writer)
Prints this throwable and its backtrace to the specified print writer.

Parameters:
writer - PrintWriter to use for output