Class ExceptionHelper
java.lang.Object
software.amazon.lambda.durable.util.ExceptionHelper
Utility class for handling exceptions
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic software.amazon.awssdk.services.lambda.model.ErrorObjectbuildErrorObject(Throwable throwable, SerDes serDes) build an ErrorObject from a Throwablestatic StackTraceElement[]deserializeStackTrace(List<String> stackTrace) serializeStackTrace(StackTraceElement[] stackTrace) static <T extends Throwable>
voidsneakyThrow(Throwable exception) Throws any exception as if it were unchecked using type erasure.static ThrowableunwrapCompletableFuture(Throwable throwable) unwrap the exception that is wrapped by CompletionException
-
Constructor Details
-
ExceptionHelper
public ExceptionHelper()
-
-
Method Details
-
sneakyThrow
Throws any exception as if it were unchecked using type erasure. This preserves the original exception type and stack trace.- Type Parameters:
T- the exception type (erased at runtime)- Parameters:
exception- the exception to throw- Throws:
T- the exception as an unchecked exception
-
unwrapCompletableFuture
unwrap the exception that is wrapped by CompletionException- Parameters:
throwable- the throwable to unwrap- Returns:
- the original Throwable that is not a CompletionException
-
buildErrorObject
public static software.amazon.awssdk.services.lambda.model.ErrorObject buildErrorObject(Throwable throwable, SerDes serDes) build an ErrorObject from a Throwable- Parameters:
throwable- the Throwable from which to build the errorObject- Returns:
- the ErrorObject
-
serializeStackTrace
-
deserializeStackTrace
-