Whole document tree
java.lang
|
Constructor Summary | |
Throwable()
Constructs a new Throwable with null as
its error message string. |
|
Throwable(String message)
Constructs a new Throwable with the specified error
message. |
Method Summary | |
Throwable |
fillInStackTrace()
Fills in the execution stack trace. |
String |
getLocalizedMessage()
Creates a localized description of this Throwable . |
String |
getMessage()
Returns the error message string of this throwable object. |
void |
printStackTrace()
Prints this Throwable and its backtrace to the
standard error stream. |
void |
printStackTrace(PrintStream s)
Prints this Throwable and its backtrace to the
specified print stream. |
void |
printStackTrace(PrintWriter s)
Prints this Throwable and its backtrace to the specified
print writer. |
String |
toString()
Returns a short description of this throwable object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Throwable()
Throwable
with null
as
its error message string. Also, the method
fillInStackTrace()
is called for this object.public Throwable(String message)
Throwable
with the specified error
message. Also, the method fillInStackTrace()
is called for
this object.message
- the error message. The error message is saved for
later retrieval by the getMessage()
method.Method Detail |
public String getMessage()
public String getLocalizedMessage()
Throwable
.
Subclasses may override this method in order to produce a
locale-specific message. For subclasses that do not override this
method, the default implementation returns the same result as
getMessage()
.Throwable
.public String toString()
Throwable
object was
created
with an error message string,
then the result is the concatenation of three strings:
getMessage()
method for this object
Throwable
object was created
with no error message string, then the name of the actual class of
this object is returned.Throwable
.public void printStackTrace()
Throwable
and its backtrace to the
standard error stream. This method prints a stack trace for this
Throwable
object on the error output stream that is
the value of the field System.err
. The first line of
output contains the result of the toString()
method for
this object. Remaining lines represent data previously recorded by
the method fillInStackTrace()
. The format of this
information depends on the implementation, but the following
example may be regarded as typical:
This example was produced by running the program:java.lang.NullPointerException at MyClass.mash(MyClass.java:9) at MyClass.crunch(MyClass.java:6) at MyClass.main(MyClass.java:3)
class MyClass { public static void main(String[] argv) { crunch(null); } static void crunch(int[] a) { mash(a); } static void mash(int[] b) { System.out.println(b[0]); } }
System.err
public void printStackTrace(PrintStream s)
Throwable
and its backtrace to the
specified print stream.s
- PrintStream
to use for outputpublic void printStackTrace(PrintWriter s)
Throwable
and its backtrace to the specified
print writer.s
- PrintWriter
to use for outputpublic Throwable fillInStackTrace()
Throwable
object information about the current state of
the stack frames for the current thread. This method is useful when
an application is re-throwing an error or exception. For example:
try { a = b / c; } catch(ArithmeticThrowable e) { a = Double.MAX_VALUE; throw e.fillInStackTrace(); }
Throwable
object.printStackTrace()
|
JavaTM 2 Platform Std. Ed. v1.3.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-2001 Sun Microsystems, Inc. 901 San Antonio Road
Palo Alto, California, 94303, U.S.A. All Rights Reserved.