public static class Errors.Rethrowing extends Errors
Errors
which is guaranteed to always throw a RuntimeException.
If we want to wrap a method with a return value, it's pointless to specify a default value because if the wrapped method fails, a RuntimeException is guaranteed to throw.
Errors.Handling, Errors.Plugins, Errors.Rethrowing, Errors.WrappedAsRuntimeException
Modifier | Constructor and Description |
---|---|
protected |
Rethrowing(Function<Throwable,RuntimeException> transform) |
Modifier and Type | Method and Description |
---|---|
<T> T |
get(Throwing.Supplier<T> supplier)
Attempts to call
supplier and rethrows any exceptions as unchecked exceptions. |
<T,R> Function<T,R> |
wrap(Throwing.Function<T,R> function)
Returns a Function which wraps
function and rethrows any exceptions as unchecked exceptions. |
<T> Predicate<T> |
wrap(Throwing.Predicate<T> predicate)
Returns a Predicate which wraps
predicate and rethrows any exceptions as unchecked exceptions. |
<T> Supplier<T> |
wrap(Throwing.Supplier<T> supplier)
Returns a Supplier which wraps
supplier and rethrows any exceptions as unchecked exceptions. |
<T,R> Function<T,R> |
wrapFunction(Throwing.Function<T,R> function)
Returns a Function which wraps
function and rethrows any exceptions as unchecked exceptions. |
<T> Predicate<T> |
wrapPredicate(Throwing.Predicate<T> predicate)
Returns a Predicate which wraps
predicate and rethrows any exceptions as unchecked exceptions. |
accept, asRuntime, asTerminal, createHandling, createRethrowing, dialog, log, rethrow, run, suppress, wrap, wrap
protected Rethrowing(Function<Throwable,RuntimeException> transform)
public <T> T get(Throwing.Supplier<T> supplier)
supplier
and rethrows any exceptions as unchecked exceptions.public <T> Supplier<T> wrap(Throwing.Supplier<T> supplier)
supplier
and rethrows any exceptions as unchecked exceptions.public <T,R> Function<T,R> wrap(Throwing.Function<T,R> function)
function
and rethrows any exceptions as unchecked exceptions.
If you are getting an error about the method wrap is ambiguous
, use
wrapFunction(com.diffplug.common.base.Throwing.Function)
or
{@link #wrapPredicate(com.diffplug.common.base.Throwing.Predicate).
public <T> Predicate<T> wrap(Throwing.Predicate<T> predicate)
predicate
and rethrows any exceptions as unchecked exceptions.
If you are getting an error about the method wrap is ambiguous
, use
wrapFunction(com.diffplug.common.base.Throwing.Function)
or
{@link #wrapPredicate(com.diffplug.common.base.Throwing.Predicate).
public <T,R> Function<T,R> wrapFunction(Throwing.Function<T,R> function)
function
and rethrows any exceptions as unchecked exceptions.public <T> Predicate<T> wrapPredicate(Throwing.Predicate<T> predicate)
predicate
and rethrows any exceptions as unchecked exceptions.