code: public static <T> UnaryOperator<T> unaryOperator(CheckedUnaryOperator<T> operator, Consumer<Throwable> handler) {
          return t -> {
              try {
                  return operator.apply(t);
              }
              catch (Throwable e) {
                  handler.accept(e);
  
                  throw new IllegalStateException("Exception handler must throw a RuntimeException", e);
              }
          };
      }
docs: Wrap a {@link CheckedUnaryOperator} in a {@link UnaryOperator} with a custom handler for checked exceptions.
  <p>
  Example:
  <code><pre>
  Stream.of("a", "b", "c").map(Unchecked.unaryOperator(
  s -> {
  if (s.length() > 10)
  throw new Exception("Only short strings allowed");
  
  return s;
  },
  e -> {
  throw new IllegalStateException(e);
  }
  ));
  </pre></code>