code: public static <R> IntFunction<R> intFunction(CheckedIntFunction<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);
              }
          };
      }
docs: Wrap a {@link CheckedIntFunction} in a {@link IntFunction} with a custom handler for checked exceptions.
  <p>
  Example:
  <code><pre>
  IntStream.of(1, 2, 3).mapToObj(Unchecked.intFunction(
  i -> {
  if (i &lt; 0)
  throw new Exception("Only positive numbers allowed");
  
  return "" + i;
  },
  e -> {
  throw new IllegalStateException(e);
  }
  ));
  </pre></code>