public static final class Errors.ConstrainedTo<E extends Throwable> extends Object
Generated by calling Errors.constrainTo(Class)
.
A fluent API for calling functions which throw an overly-broad exception (e.g. Throwable, Exception) in way that will throw the given exception unchanged, and rethrow other exceptions wrapped up in a RuntimeException according to Errors.asRuntime(Throwable)
.
Modifier and Type | Method and Description |
---|---|
<T> T |
get(Throwing.Supplier<T> supplier)
Returns the value generated by the given supplier.
|
void |
run(Throwing.Runnable runnable)
Runs the given runnable.
|
public void run(Throwing.Runnable runnable) throws E extends Throwable
Runs the given runnable. If an exception of the constrained type is thrown, it is rethrown unchanged. If an exception of a different type is thrown, is is rethrown according to Errors.asRuntime(Throwable)
.
public <T> T get(Throwing.Supplier<T> supplier) throws E extends Throwable
Returns the value generated by the given supplier. If an exception of the constrained type is thrown, it is rethrown unchanged. If an exception of a different type is thrown, is is rethrown according to Errors.asRuntime(Throwable)
.