public static <T> List<CompletableFuture<T>> mapExceptionally(
        List<CompletableFuture<T>> futures,
        Function<Throwable, ? extends T> fn
    ) {
        final List<CompletableFuture<T>> results = new ArrayList<>(futures.size());
        futures.forEach(future -> results.add(future.exceptionally(fn)));
        return results;
    }
Applies the given exception handler to all the futures provided in the list
and returns a new list of futures.

@param futures   A list of futures.
@param fn        A function taking an exception to handle it.
@return A list of futures.
server-common/src/main/java/org/apache/kafka/server/util/FutureUtils.java