public abstract class Errors
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Errors.Handling
An Errors which is free to rethrow the exception, but it might not.
|
static interface |
Errors.Plugins
Namespace for the plugins which Errors supports.
|
static class |
Errors.Rethrowing
An Errors which is guaranteed to always throw a RuntimeException.
|
Modifier and Type | Field and Description |
---|---|
protected java.util.function.Consumer<java.lang.Throwable> |
handler |
Modifier | Constructor and Description |
---|---|
protected |
Errors(java.util.function.Consumer<java.lang.Throwable> error) |
Modifier and Type | Method and Description |
---|---|
static java.lang.RuntimeException |
asRuntime(java.lang.Throwable e)
Converts the given exception to a RuntimeException, with a minimum of new exceptions to obscure the cause.
|
static Errors.Handling |
createHandling(java.util.function.Consumer<java.lang.Throwable> handler)
Creates an Errors.Handling which passes any exceptions it receives
to the given handler.
|
static Errors.Rethrowing |
createRethrowing(java.util.function.Function<java.lang.Throwable,java.lang.RuntimeException> transform)
Creates an Errors.Rethrowing which transforms any exceptions it receives into a RuntimeException
as specified by the given function, and then throws that RuntimeException.
|
static Errors.Handling |
dialog()
Opens a dialog to notify the user of any exceptions.
|
void |
handle(java.lang.Throwable error)
Passes the given error to be handled by the Errors.
|
static Errors.Handling |
log()
Logs any exceptions.
|
static Errors.Rethrowing |
rethrow()
Rethrows any exceptions as runtime exceptions.
|
void |
run(Throwing.Runnable runnable)
Attempts to run the given runnable.
|
static Errors.Handling |
suppress()
Suppresses errors entirely.
|
<T> java.util.function.Consumer<T> |
wrap(Throwing.Consumer<T> consumer)
Returns a Consumer whose exceptions are handled by this Errors.
|
java.lang.Runnable |
wrap(Throwing.Runnable runnable)
Returns a Runnable whose exceptions are handled by this Errors.
|
public static Errors.Rethrowing createRethrowing(java.util.function.Function<java.lang.Throwable,java.lang.RuntimeException> transform)
public static Errors.Handling createHandling(java.util.function.Consumer<java.lang.Throwable> handler)
public static Errors.Handling suppress()
public static Errors.Rethrowing rethrow()
public static Errors.Handling log()
public static Errors.Handling dialog()
public void handle(java.lang.Throwable error)
public void run(Throwing.Runnable runnable)
public java.lang.Runnable wrap(Throwing.Runnable runnable)
public <T> java.util.function.Consumer<T> wrap(Throwing.Consumer<T> consumer)
public static java.lang.RuntimeException asRuntime(java.lang.Throwable e)