Package org.kiwiproject.concurrent
Class AsyncException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- org.kiwiproject.concurrent.AsyncException
-
- All Implemented Interfaces:
Serializable
public class AsyncException extends RuntimeException
A subclassRuntimeExceptionused to indicate problems in asynchronous code.- See Also:
- Serialized Form
- Implementation Note:
- Sadly, we cannot make the
CompletableFuturegeneric. It will not compile, and the compiler reports the following error: "a generic class may not extend java.lang.Throwable". However, we can fake it by declaringgetFuture()in a generic manner (and suppressing the unchecked warning). This means you could still receive aClassCastExceptionat runtime if you attempt a cast to an invalid type.
-
-
Constructor Summary
Constructors Constructor Description AsyncException(String message, Throwable cause, CompletableFuture future)Construct instance with given message, cause, and future.AsyncException(String message, CompletableFuture future)Construct instance with given message and future.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> CompletableFuture<T>getFuture()The future which causes the exception.-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
-
-
-
Constructor Detail
-
AsyncException
public AsyncException(String message, @Nullable CompletableFuture future)
Construct instance with given message and future.- Parameters:
message- the exception messagefuture- theCompletableFuturethat caused the error, may be null
-
AsyncException
public AsyncException(String message, Throwable cause, @Nullable CompletableFuture future)
Construct instance with given message, cause, and future.- Parameters:
message- the exception messagecause- the original cause of the exceptionfuture- theCompletableFuturethat caused the error, may be null
-
-
Method Detail
-
getFuture
@Nullable public <T> CompletableFuture<T> getFuture()
The future which causes the exception. May be null.- Type Parameters:
T- the generic type of the CompletableFuture- Returns:
- the future causing this exception, or null
-
-