Class ExceptionHandlingUtils
java.lang.Object
software.amazon.awssdk.http.nio.netty.internal.utils.ExceptionHandlingUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
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 Details
-
tryCatch
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
-