Class ExceptionHandlingUtils
- java.lang.Object
-
- software.amazon.awssdk.http.nio.netty.internal.utils.ExceptionHandlingUtils
-
public final class ExceptionHandlingUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Method Detail
-
tryCatch
public static void tryCatch(Runnable executable, Consumer<Throwable> errorNotifier)
Runs a task within try-catch block. All exceptions thrown from the execution will be sent to errorNotifier.This is useful for single-line executable code to avoid try-catch code clutter.
- Parameters:
executable
- the task to runerrorNotifier
- error notifier
-
tryCatchFinally
public static <T> T tryCatchFinally(Callable<T> executable, Consumer<Throwable> errorNotifier, Runnable cleanupExecutable)
Runs a task within try-catch-finally block. All exceptions thrown from the execution will be sent to errorNotifier.This is useful for single-line executable code to avoid try-catch code clutter.
- Type Parameters:
T
- the type of the object to be returned- Parameters:
executable
- the task to runerrorNotifier
- the error notifiercleanupExecutable
- the cleanup executable- Returns:
- the object if succeeds
-
-