UndeclaredThrowableException (Java SE 19 & JDK 19) (original) (raw)
All Implemented Interfaces:
[Serializable](../../io/Serializable.html "interface in java.io")
public class UndeclaredThrowableException extends RuntimeException
Thrown by a method invocation on a proxy instance if its invocation handler's invoke method throws a checked exception (a Throwable
that is not assignable to RuntimeException
or Error
) that is not assignable to any of the exception types declared in thethrows
clause of the method that was invoked on the proxy instance and dispatched to the invocation handler.
An UndeclaredThrowableException
instance contains the undeclared checked exception that was thrown by the invocation handler, and it can be retrieved with thegetUndeclaredThrowable()
method.UndeclaredThrowableException
extendsRuntimeException
, so it is an unchecked exception that wraps a checked exception.
Since:
1.3
See Also:
Constructor Summary
Constructors
Constructs an UndeclaredThrowableException
with the specified Throwable
.
Constructs an UndeclaredThrowableException
with the specified Throwable
and a detail message.
Method Summary
Returns the Throwable
instance wrapped in thisUndeclaredThrowableException
, which may be null
.
Methods declared in class java.lang.Throwable
[addSuppressed](../Throwable.html#addSuppressed%28java.lang.Throwable%29), [fillInStackTrace](../Throwable.html#fillInStackTrace%28%29), [getCause](../Throwable.html#getCause%28%29), [getLocalizedMessage](../Throwable.html#getLocalizedMessage%28%29), [getMessage](../Throwable.html#getMessage%28%29), [getStackTrace](../Throwable.html#getStackTrace%28%29), [getSuppressed](../Throwable.html#getSuppressed%28%29), [initCause](../Throwable.html#initCause%28java.lang.Throwable%29), [printStackTrace](../Throwable.html#printStackTrace%28%29), [printStackTrace](../Throwable.html#printStackTrace%28java.io.PrintStream%29), [printStackTrace](../Throwable.html#printStackTrace%28java.io.PrintWriter%29), [setStackTrace](../Throwable.html#setStackTrace%28java.lang.StackTraceElement%5B%5D%29), [toString](../Throwable.html#toString%28%29)
Constructor Details
UndeclaredThrowableException
public UndeclaredThrowableException(Throwable undeclaredThrowable)
Constructs anUndeclaredThrowableException
with the specifiedThrowable
.
Parameters:
undeclaredThrowable
- the undeclared checked exception that was thrownUndeclaredThrowableException
public UndeclaredThrowableException(Throwable undeclaredThrowable,String s)
Constructs anUndeclaredThrowableException
with the specifiedThrowable
and a detail message.
Parameters:
undeclaredThrowable
- the undeclared checked exception that was thrown
s
- the detail messageMethod Details
getUndeclaredThrowable
public Throwable getUndeclaredThrowable()
Returns theThrowable
instance wrapped in thisUndeclaredThrowableException
, which may benull
.
API Note:
This method predates the general-purpose exception chaining facility. The Throwable.getCause() method is now the preferred means of obtaining this information.
Returns:
the undeclared checked exception that was thrown