private void errorHandler(Function<? super Throwable, ?> errorHandler) {
        if (this.errorHandler == null) {
            this.errorHandler = errorHandler;
        } else {
            this.errorHandler = this.errorHandler.andThen(obj -> {
                if (obj instanceof Throwable) {
                    Object result = null;
                    try {
                        result = errorHandler.apply((Throwable) obj);
                    } catch (Throwable ex) {
                        logger.warn("Unexpected exception while handling {}", obj, ex);
                    }

                    if (result != null) {
                        return result;
                    }
                }
                // Not handled or recovered already.
                return obj;
            });
        }
    }
Transforms a {@link Throwable} raised while receiving the response by applying the specified
{@link Function}. If a {@code null} value is returned, the original cause will be used as is.
core/src/main/java/com/linecorp/armeria/client/FutureTransformingRequestPreparation.java