code: public static DoubleToLongFunction doubleToLongFunction(CheckedDoubleToLongFunction function, Consumer<Throwable> handler) {
          return t -> {
              try {
                  return function.applyAsLong(t);
              }
              catch (Throwable e) {
                  handler.accept(e);
  
                  throw new IllegalStateException("Exception handler must throw a RuntimeException", e);
              }
          };
      }
docs: Wrap a {@link CheckedDoubleToLongFunction} in a {@link DoubleToLongFunction} with a custom handler for checked exceptions.
  <p>
  Example:
  <code><pre>
  DoubleStream.of(1.0, 2.0, 3.0).mapToLong(Unchecked.doubleToLongFunction(
  d -> {
  if (d &lt; 0.0)
  throw new Exception("Only positive numbers allowed");
  
  return (long) d;
  },
  e -> {
  throw new IllegalStateException(e);
  }
  ));
  </pre></code>