public class InvocationTargetRuntimeException extends RuntimeException
InvocationTargetRuntimeException class is a custom runtime exception
that is thrown when a method's invocation on the target object throws an exception.
This class helps in wrapping the exception thrown by the target method
into an unchecked exception.
For example, if a reflective method invocation through java.lang.reflect.Method
throws an exception, this class can be used to wrap and rethrow it as a
runtime exception.
This is useful in scenarios where the client code invoking the method is not expecting or is not capable of handling checked exceptions thrown by the method.
InvocationTargetException,
Serialized Form| Constructor and Description |
|---|
InvocationTargetRuntimeException(@NotNull Throwable cause)
Constructs a new
InvocationTargetRuntimeException with the
specified cause. |
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringpublic InvocationTargetRuntimeException(@NotNull
@NotNull Throwable cause)
InvocationTargetRuntimeException with the
specified cause. If the cause is an instance of
InvocationTargetException, the actual exception thrown by
the target method is extracted and set as the cause for this exception.
Otherwise, the supplied cause is set as the cause.cause - The cause of this exception. This is usually the exception
thrown by the method that was invoked.Copyright © 2024. All rights reserved.