public abstract class Errors
Errors makes it easy to create implementations of the standard
functional interfaces (which don't allow checked exceptions).
Even for cases where you aren't required to stuff some code into a
functional interface, Errors is useful as a concise way to
specify how errors will be handled.
public 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.
If that function happens to throw an unchecked error itself, that'll work just fine.
public 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.
The handler is free to throw a RuntimeException if it wants to. If it always
throws a RuntimeException, then you should instead create an Errors.Rethrowing
Opens a dialog to notify the user of any exceptions. It should be used in cases where
an error is too severe to be silently logged.
By default, dialog() opens a JOptionPane. To modify this behavior in your application,
call DurianPlugins.set(Errors.Plugins.Dialog.class, error -> openMyDialog(error));
For a non-interactive console application, a good implementation of would probably
print the error and call System.exit().
public void handle(java.lang.Throwable error)
Passes the given error to be handled by the Errors.