initCause(cause) - Java Throwable's method
Method java.lang.Throwable
Throwable initCause(
Throwable cause
)
This method can be called at most once. It is generally called from within the constructor, or immediately after creating the throwable. If this throwable was created with Throwable(Throwable)
or Throwable(String,Throwable)
, this method cannot be called even once.
- Parameters:
-
cause
- the cause (which is saved for later retrieval by thegetCause()
method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
- Returns:
- a reference to this
Throwable
instance.
- Throws:
-
IllegalArgumentException
- ifcause
is this throwable. (A throwable cannot be its own cause.) -
IllegalStateException
- if this throwable was created withThrowable(Throwable)
orThrowable(String,Throwable)
, or this method has already been called on this throwable.
- Since:
- Java 1.4