public final class ExceptionHandlingUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
tryCatch(Runnable executable,
Consumer<Throwable> errorNotifier)
Runs a task within try-catch block.
|
static <T> T |
tryCatchFinally(Callable<T> executable,
Consumer<Throwable> errorNotifier,
Runnable cleanupExecutable)
Runs a task within try-catch-finally block.
|
public static void tryCatch(Runnable executable, Consumer<Throwable> errorNotifier)
This is useful for single-line executable code to avoid try-catch code clutter.
executable - the task to runerrorNotifier - error notifierpublic static <T> T tryCatchFinally(Callable<T> executable, Consumer<Throwable> errorNotifier, Runnable cleanupExecutable)
This is useful for single-line executable code to avoid try-catch code clutter.
T - the type of the object to be returnedexecutable - the task to runerrorNotifier - the error notifiercleanupExecutable - the cleanup executableCopyright © 2023. All rights reserved.