Wraps the specified function to ensure that if any exception occurs, it is of the specified type and/or with the specified message. If no exception occurs, the function's return value is returned as expected. If fn throws an exception, its type is checked. If it is already of type {@co
(CheckedFunction<T, R> fn, Class<E> exClass, String msg)
| 49 | * @return the wrapping function instance. |
| 50 | */ |
| 51 | public static <T, R, E extends RuntimeException> Function<T, R> wrapFmt(CheckedFunction<T, R> fn, Class<E> exClass, String msg) { |
| 52 | return new PropagatingExceptionFunction<>(fn, exClass, new FormattedStringFunction<T>(msg)); |
| 53 | } |
| 54 | |
| 55 | public static <T, R, E extends RuntimeException> Function<T, R> wrap(Function<T, R> fn, Class<E> exClass, String fmt, Object... args) { |
| 56 | return new PropagatingExceptionFunction<>(new DelegatingCheckedFunction<>(fn), exClass, new FormattedStringSupplier(fmt, args)); |
no outgoing calls
no test coverage detected