java.lang.Throwable
java.lang.Object
java.lang.Error, java.lang.Exception
java.io.Serializable
JDK 1.0 or later
The Throwable class is the superclass of all objects that can be thrown by the throw statement in Java. This is a requirement of the throw statement.
A Throwable object can have an associated message that provides more detail about the particular error or exception that is being thrown.
The Throwable class provides a method that outputs information about the state of the system when an exception object is created. This method can be useful in debugging Java programs.
The subclasses of Throwable that are provided with Java do not add functionality to Throwable. Instead, they offer more specific classifications of errors and exceptions.
public class java.lang.Throwable extends java.lang.Object implements java.lang.Serializable { // Constructors public Throwable(); public Throwable(String message); // Instance Methods public native Throwable fillInStackTrace(); public String getLocalizedMessage(); // New in 1.1 public String getMessage(); public void printStackTrace(); public void printStackTrace(PrintStream s); public void printStackTrace(PrintWriter s); // New in 1.1 public String toString(); }
Creates a Throwable object with no associated message. This constructor calls fillInStackTrace() so that information is available for printStackTrace().
A message string to be associated with the object.
Create a Throwable object with an associated message. This constructor calls fillInStackTrace() so that information is available for printStackTrace().
A reference to this object.
This method puts stack trace information in this Throwable object. It is not usually necessary to explicitly call this method, since it is called by the constructors of the class. However, this method can be useful when rethrowing an object. If the stack trace information in the object needs to reflect the location that the object is rethrows from, fillInStackTrace() should be called.
New as of JDK 1.1
A localized version of the String object associated with this Throwable object, or null if there is no message associated with this object.
This method creates a localized version of the message that was associated with this object by its constructor.
The getLocalizedMessage() method in Throwable always returns the same result as getMessage(). A subclass must override this method to produce a locale-specific message.
The String object associated with this Throwable object, or null if there is no message associated with this object.
This method returns any string message that was associated with this object by its constructor.
This method outputs the string representation of this Throwable object and a stack trace to System.err.
A java.io.PrintStream object.
This method outputs the string representation of this Throwable object and a stack trace to the specified PrintStream object.
New as of JDK 1.1
A java.io.PrintWriter object.
This method outputs the string representation of this Throwable object and a stack trace to the specified PrintWriter object.
A string representation of this object.
Object.toString()
This method returns a string representation of this Throwable object.
Method |
Inherited From |
Method |
Inherited From |
---|---|---|---|
clone() |
Object |
equals(Object) |
Object |
finalize() |
Object |
getClass() |
Object |
hashCode() |
Object |
notify() |
Object |
notifyAll() |
Object |
wait() |
Object |
wait(long) |
Object |
wait(long, int) |
Object |