in src/main/java/com/spotify/github/async/Async.java [40:53]
public static <T> CompletableFuture<T> exceptionallyCompose(
final CompletableFuture<T> future, final Function<Throwable, CompletableFuture<T>> handler) {
return future
.handle(
(result, throwable) -> {
if (throwable != null) {
return handler.apply(throwable);
} else {
return CompletableFuture.completedFuture(result);
}
})
.thenCompose(Function.identity());
}