public static <R> Supplier<R> doAndHandle(final CheckedSupplier<R> function, final CheckedFunction<Throwable, R> errorHandler) {
        return () -> {
            try {
                return function.get();
            } catch (final Throwable e) {
                try {
                    LoggingUtils.warn(LOGGER, e);
                    return errorHandler.apply(e);
                } catch (final Throwable ex) {
                    if (ex instanceof final RuntimeException re) {
                        throw re;
                    }
                    throw new IllegalArgumentException(ex);
                }
            }
        };
    }
Do and handle supplier.

@param <R>          the type parameter
@param function     the function
@param errorHandler the error handler
@return the supplier
core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/function/FunctionUtils.java