exceptionally

The CompletableFuture method that supplies a fallback result when an earlier stage has failed.

In more detail

It receives the failure and returns a replacement value, turning a failed chain back into a successful one. Keep the original cause in logs when you recover this way.

Example

.exceptionally(ex -> "fallback")

Related terms

Taught in

References