Compartilhar via


Throwable Constructors

Definition

Overloads

Throwable()

Constructs a new throwable with null as its detail message.

Throwable(Throwable)

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).

Throwable(String)

Constructs a new throwable with the specified detail message.

Throwable(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Throwable(String, Throwable)

Constructs a new throwable with the specified detail message and cause.

Throwable(String, Throwable, Boolean, Boolean)

Constructs a new throwable with the specified detail message, cause, #addSuppressed suppression enabled or disabled, and writable stack trace enabled or disabled.

Throwable()

Constructs a new throwable with null as its detail message.

[Android.Runtime.Register(".ctor", "()V", "")]
public Throwable ();
Attributes

Remarks

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.

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

Java documentation for java.lang.Throwable.Throwable().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Throwable(Throwable)

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).

[Android.Runtime.Register(".ctor", "(Ljava/lang/Throwable;)V", "")]
public Throwable (Java.Lang.Throwable? cause);
[<Android.Runtime.Register(".ctor", "(Ljava/lang/Throwable;)V", "")>]
new Java.Lang.Throwable : Java.Lang.Throwable -> Java.Lang.Throwable

Parameters

cause
Throwable

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.)

Attributes

Remarks

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 #fillInStackTrace() method is called to initialize the stack trace data in the newly created throwable.

Added in 1.4.

Java documentation for java.lang.Throwable.Throwable(java.lang.Throwable).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Throwable(String)

Constructs a new throwable with the specified detail message.

[Android.Runtime.Register(".ctor", "(Ljava/lang/String;)V", "")]
public Throwable (string? message);
[<Android.Runtime.Register(".ctor", "(Ljava/lang/String;)V", "")>]
new Java.Lang.Throwable : string -> Java.Lang.Throwable

Parameters

message
String

the detail message. The detail message is saved for later retrieval by the #getMessage() method.

Attributes

Remarks

Constructs a new throwable with the specified detail message. The cause is not initialized, and may subsequently be initialized by a call to #initCause.

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

Java documentation for java.lang.Throwable.Throwable(java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Throwable(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

public Throwable (IntPtr handle, Android.Runtime.JniHandleOwnership transfer);
new Java.Lang.Throwable : nativeint * Android.Runtime.JniHandleOwnership -> Java.Lang.Throwable

Parameters

handle
IntPtr

nativeint

A IntPtrcontaining a Java Native Interface (JNI) object reference.

transfer
JniHandleOwnership

A JniHandleOwnershipindicating how to handle handle

Remarks

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Throwable(String, Throwable)

Constructs a new throwable with the specified detail message and cause.

[Android.Runtime.Register(".ctor", "(Ljava/lang/String;Ljava/lang/Throwable;)V", "")]
public Throwable (string? message, Java.Lang.Throwable? cause);
[<Android.Runtime.Register(".ctor", "(Ljava/lang/String;Ljava/lang/Throwable;)V", "")>]
new Java.Lang.Throwable : string * Java.Lang.Throwable -> Java.Lang.Throwable

Parameters

message
String

the detail message (which is saved for later retrieval by the #getMessage() method).

cause
Throwable

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.)

Attributes

Remarks

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 #fillInStackTrace() method is called to initialize the stack trace data in the newly created throwable.

Added in 1.4.

Java documentation for java.lang.Throwable.Throwable(java.lang.String, java.lang.Throwable).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Throwable(String, Throwable, Boolean, Boolean)

Constructs a new throwable with the specified detail message, cause, #addSuppressed suppression enabled or disabled, and writable stack trace enabled or disabled.

[Android.Runtime.Register(".ctor", "(Ljava/lang/String;Ljava/lang/Throwable;ZZ)V", "")]
protected Throwable (string? message, Java.Lang.Throwable? cause, bool enableSuppression, bool writableStackTrace);
[<Android.Runtime.Register(".ctor", "(Ljava/lang/String;Ljava/lang/Throwable;ZZ)V", "")>]
new Java.Lang.Throwable : string * Java.Lang.Throwable * bool * bool -> Java.Lang.Throwable

Parameters

message
String

the detail message.

cause
Throwable

the cause. (A null value is permitted, and indicates that the cause is nonexistent or unknown.)

enableSuppression
Boolean

whether or not suppression is enabled or disabled

writableStackTrace
Boolean

whether or not the stack trace should be writable

Attributes

Remarks

Constructs a new throwable with the specified detail message, cause, #addSuppressed 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 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.

Added in 1.7.

Java documentation for java.lang.Throwable.Throwable(java.lang.String, java.lang.Throwable, boolean, boolean).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to