CompletableFuture.completedFuture() returns a CompletedFuture
that is already completed with the given value.
How do we construct a CompletableFuture
that is already completed exceptionally?
Meaning, instead of returning a value I want the future to throw an exception.
@Async
or withthenCompose()
)CompletionStage
. Why? Because the caller wants to validate input parameters synchronously before chaining asynchronousCompletionStage
s after it, and it needs any exceptions thrown by precondition validation to get handled byexceptionally()
.