GeezerVison is showing docs.oracle.com — Throwable (Java Platform SE 8 )
Java™ Platform Standard Ed. 8
compact1, compact2, compact3
java.lang
Class Throwable
-
-
Constructor Summary
Constructors
| Modifier |
Constructor |
Description |
|
Throwable() |
Constructs a new throwable with null as its detail message.
|
|
Throwable(String message) |
Constructs a new throwable with the specified detail message.
|
|
Throwable(String message,
Throwable cause) |
Constructs a new throwable with the specified detail message and
cause.
|
protected |
Throwable(String message,
Throwable cause,
boolean enableSuppression,
boolean writableStackTrace) |
Constructs a new throwable with the specified detail message,
cause, suppression enabled or
disabled, and writable stack trace enabled or disabled.
|
|
Throwable(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).
|
-
-
Constructor Detail
-
Throwable
public Throwable()
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 fillInStackTrace() method is called to initialize
the stack trace data in the newly created throwable.
-
Throwable
protected Throwable(String message,
Throwable cause,
boolean enableSuppression,
boolean writableStackTrace)
Constructs a new throwable with the specified detail message,
cause, suppression enabled or
disabled, and writable stack trace enabled or disabled. If
suppression is disabled, getSuppressed() for this object
will return a zero-length array and calls to addSuppressed(java.lang.Throwable) that would otherwise append an exception to the
suppressed list will have no effect. If the writable stack
trace is false, this constructor will not call fillInStackTrace(), a null will be written to the
stackTrace field, and subsequent calls to fillInStackTrace and setStackTrace(StackTraceElement[]) will not set the stack
trace. If the writable stack trace is false, getStackTrace() will return a zero length array.
Note that the other constructors of Throwable treat
suppression as being enabled and the stack trace as being
writable. Subclasses of Throwable should document any
conditions under which suppression is disabled and document
conditions under which the stack trace is not writable.
Disabling of suppression should only occur in exceptional
circumstances where special requirements exist, such as a
virtual machine reusing exception objects under low-memory
situations. Circumstances where a given exception object is
repeatedly caught and rethrown, such as to implement control
flow between two sub-systems, is another situation where
immutable throwable objects would be appropriate.
- Parameters:
message - the detail message.
cause - the cause. (A null value is permitted,
and indicates that the cause is nonexistent or unknown.)
enableSuppression - whether or not suppression is enabled or disabled
writableStackTrace - whether or not the stack trace should be
writable
- Since:
- 1.7
- See Also:
OutOfMemoryError,
NullPointerException,
ArithmeticException
-
Method Detail
-
getLocalizedMessage
public String getLocalizedMessage()
Creates a localized description of this 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().
- Returns:
- The localized description of this throwable.
- Since:
- JDK1.1
-
toString
public String toString()
Returns a short description of this throwable.
The result is the concatenation of:
- the name of the class of this object
- ": " (a colon and a space)
- the result of invoking this object's
getLocalizedMessage()
method
If getLocalizedMessage returns null, then just
the class name is returned.
- Overrides:
toString in class Object
- Returns:
- a string representation of this throwable.
Java™ Platform Standard Ed. 8
Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
|