java.lang
Class Throwable

java.lang.Object
  extended by java.lang.Throwable
Direct Known Subclasses:
Error, Exception

public class Throwable
extends Object

All exceptions and errors extend this class.


Constructor Summary
Throwable()
          Create a Throwable object.
Throwable(String message)
          Create a Throwable object.
Throwable(String message, Throwable cause)
          Create a Throwable object.
Throwable(Throwable cause)
          Create a Throwable object.
 
Method Summary
 void addSuppressed(Throwable t)
          Currently unimplemented.
 Throwable fillInStackTrace()
          Capture a stack trace.
 Throwable getCause()
          Returns the cause of this throwable or null if the cause is nonexistent or unknown.
 String getLocalizedMessage()
          Can be overridden, to return localized messages.
 String getMessage()
          Return the message associated with this Throwable object.
 Throwable initCause(Throwable cause)
          Initializes the cause of this throwable to the specified value.
 void printStackTrace()
          Print details of the exception/error on the system error stream.
 void printStackTrace(PrintStream s)
          Print details of the exception/error to the provided stream.
 String toString()
          Return a string version of the Throwable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Throwable

public Throwable()
Create a Throwable object. Call fillInStackTrace to create a trace of stack when the Throwable was created.


Throwable

public Throwable(String message)
Create a Throwable object. Call fillInStackTrace to create a trace of stack when the Throwable was created. Set the message to the provided string.

Parameters:
message - Message providing details of the error/exception.

Throwable

public Throwable(String message,
                 Throwable cause)
Create a Throwable object. Call fillInStackTrace to create a trace of stack when the Throwable was created. Set the message to the provided string. Calls initCause to set the cause of the Throwable.

Parameters:
message - Message providing details of the error/exception.
cause - the cause (can be null)

Throwable

public Throwable(Throwable cause)
Create a Throwable object. Call fillInStackTrace to create a trace of stack when the Throwable was created. Set the message to be cause.toString (if cause is not null). Calls initCause to set the cause of the Throwable.

Parameters:
cause - the cause (can be null)
Method Detail

initCause

public Throwable initCause(Throwable cause)
Initializes the cause of this throwable to the specified value.

Parameters:
cause - The cause (can be null)
Returns:
a reference to this throwable

getCause

public Throwable getCause()
Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Returns:
the cause or null.

addSuppressed

public final void addSuppressed(Throwable t)
Currently unimplemented.

Parameters:
t -

getLocalizedMessage

public String getLocalizedMessage()
Can be overridden, to return localized messages. The default implementation returns the same as getMessage().

Returns:
Localized message string or null if there is no message

getMessage

public String getMessage()
Return the message associated with this Throwable object.

Returns:
Message string or null if there is no message.

toString

public String toString()
Return a string version of the Throwable. This will consist of details of the actual class and the detail message if set.

Overrides:
toString in class Object
Returns:
A string representation.

fillInStackTrace

public Throwable fillInStackTrace()
Capture a stack trace. Note that the frames containing this (and other calls directly relating to the Throwable object). will be omitted.

Returns:
The Throwable object.

printStackTrace

public void printStackTrace(PrintStream s)
Print details of the exception/error to the provided stream. The details will contain the throwable class, the text of the detail message (if any) and a series of lines providing a stack trace at the time the Throwable was created.

Parameters:
s - The print stream on which to output the trace.

printStackTrace

public void printStackTrace()
Print details of the exception/error on the system error stream. See