public class SafeExecutionUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
safeExecute(Runnable toExecute,
String loggingMessage,
boolean propagateExceptions,
org.slf4j.Logger logger)
Safely executes a piece of logic.
|
static <T> T |
safeExecuteWithDefaultOnThrowable(Supplier<T> resultSupplier,
T onFailReturnValue,
String loggingMessage,
boolean propagateExceptions,
org.slf4j.Logger logger)
Returns the value obtained from the or returns the if a
Throwable
is thrown. |
public static <T> T safeExecuteWithDefaultOnThrowable(Supplier<T> resultSupplier, T onFailReturnValue, String loggingMessage, boolean propagateExceptions, org.slf4j.Logger logger)
Throwable
is thrown.T - the generic type of the result.resultSupplier - the Supplier to get the result from.onFailReturnValue - the value to return in case a Throwable is thrown.loggingMessage - the logging message.propagateExceptions - if the exceptions should be propagatedlogger - logger used for informing tracing errors.public static void safeExecute(Runnable toExecute, String loggingMessage, boolean propagateExceptions, org.slf4j.Logger logger)
toExecute - the piece of logic to execute.loggingMessage - the logging message if a throwablepropagateExceptions - if the exceptions should be propagatedlogger - logger used for informing tracing errors.Copyright © 2003–2023 MuleSoft, Inc.. All rights reserved.