public static <R> DoubleFunction<R> doubleFunction(CheckedDoubleFunction<R> function, Consumer<Throwable> handler) {
        return t -> {
            try {
                return function.apply(t);
            }
            catch (Throwable e) {
                handler.accept(e);

                throw new IllegalStateException("Exception handler must throw a RuntimeException", e);
            }
        };
    }
Wrap a {@link CheckedDoubleFunction} in a {@link DoubleFunction} with a custom handler for checked exceptions.
<p>
Example:
<pre><code>
DoubleStream.of(1.0, 2.0, 3.0).mapToObj(Unchecked.doubleFunction(
    d -> {
        if (d &lt; 0.0)
            throw new Exception("Only positive numbers allowed");

        return "" + d;
    },
    e -> {
        throw new IllegalStateException(e);
    }
));
</code></pre>
jOOL-java-8/src/main/java/org/jooq/lambda/Unchecked.java