Package org.jtrim2.concurrent
Class TaskExecutionException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.jtrim2.concurrent.TaskExecutionException
- All Implemented Interfaces:
Serializable
Defines that an asynchronously executed task has thrown an unchecked
exception. This exception is the counter part of the
java.util.concurrent.ExecutionException but unlike
ExecutionException, the TaskExecutionException is an
unchecked exception (which makes sense since the submitted tasks are not
allowed to throw checked exceptions).
The cause of TaskExecutionException is the exception actually thrown
by the asynchronously executed task and is never null. That is,
getCause() will never returns null.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionTaskExecutionException(String message, Throwable cause) Creates a newTaskExecutionExceptionwith a given cause and exception message.TaskExecutionException(Throwable cause) Creates a newTaskExecutionExceptionwith a given cause. -
Method Summary
Modifier and TypeMethodDescriptionfinal RuntimeExceptionThrows the cause of this exception if it is an instance ofErrororRuntimeException, or throws aRuntimeExceptionexception with the cause of this exception as the cause of the thrown exception.final <T extends Throwable>
RuntimeExceptionrethrowCause(Class<? extends T> checkedType) Throws the cause of this exception if it is an instance ofErrororRuntimeExceptionor is of the given type, or throws aRuntimeExceptionexception with the cause of this exception as the cause of the thrown exception.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
TaskExecutionException
Creates a newTaskExecutionExceptionwith a given cause. The cause defines the actual exception thrown by the asynchronously executed task.- Parameters:
cause- the exception thrown by the asynchronously executed task. This argument cannot benull.- Throws:
NullPointerException- thrown if the specified cause isnull
-
TaskExecutionException
Creates a newTaskExecutionExceptionwith a given cause and exception message. The cause defines the actual exception thrown by the asynchronously executed task.- Parameters:
message- theStringto be returned by thegetMessage()method. This argument is allowed to benull.cause- the exception thrown by the asynchronously executed task. This argument cannot benull.- Throws:
NullPointerException- thrown if the specified cause isnull
-
-
Method Details
-
rethrowCause
Throws the cause of this exception if it is an instance ofErrororRuntimeException, or throws aRuntimeExceptionexception with the cause of this exception as the cause of the thrown exception.Note that this method never returns normally and always throws an exception. The return value is simply for convenience, so that you can write:
throw rethrowCause();This allows the Java compiler to detect that the code after this method is not reachable.
- Returns:
- this method never returns, the return value is provided solely for convenience
-
rethrowCause
public final <T extends Throwable> RuntimeException rethrowCause(Class<? extends T> checkedType) throws T Throws the cause of this exception if it is an instance ofErrororRuntimeExceptionor is of the given type, or throws aRuntimeExceptionexception with the cause of this exception as the cause of the thrown exception.Note that this method never returns normally and always throws an exception. The return value is simply for convenience, so that you can write:
throw rethrowCause(MyException.class);This allows the Java compiler to detect that the code after this method is not reachable.
- Type Parameters:
T- the type of the checked exception type which might be rethrown as is- Parameters:
checkedType- a type defining aThrowable, if the cause implements this class, it is simply rethrown instead of wrapped. This argument cannot benull. However, ifnullis passed for this argument, the cause is still rethrown but aNullPointerExceptionwill be attached to it as a suppressed exception.- Returns:
- this method never returns, the return value is provided solely for convenience
- Throws:
T- thrown if the given exception is an instance of the given class
-