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 software.amazon.awssdk.services.lambda.model.ErrorObjectbuildErrorObject(Throwable throwable, SerDes serDes, SerDesContext context) Builds an error using the operation's context-aware serializer.static StackTraceElement[]deserializeStackTrace(List<String> stackTrace) Deserializes a list of pipe-delimited strings back into stack trace elements.serializeStackTrace(StackTraceElement[] stackTrace) Serializes a stack trace to a list of pipe-delimited strings in the formatclassName|methodName|fileName|lineNumber.static <T extends Throwable>
voidsneakyThrow(Throwable exception) Throws any exception as if it were unchecked using type erasure.static ThrowableunwrapAsyncFailure(Throwable failure) Inspects asynchronous wrappers for fatal causes without looping on cyclic or unreadable cause chains.static ThrowableunwrapCompletableFuture(Throwable throwable) unwrap the exception that is wrapped by CompletionExceptionstatic ThrowableunwrapInvocationFailure(Throwable failure) Removes completion transport wrappers while retaining application ExecutionException values, except when an asynchronous wrapper contains a fatal JVM error.
-
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
-
unwrapAsyncFailure
Inspects asynchronous wrappers for fatal causes without looping on cyclic or unreadable cause chains. -
unwrapInvocationFailure
Removes completion transport wrappers while retaining application ExecutionException values, except when an asynchronous wrapper contains a fatal JVM error. Each cause accessor is read at most once. -
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
-
buildErrorObject
public static software.amazon.awssdk.services.lambda.model.ErrorObject buildErrorObject(Throwable throwable, SerDes serDes, SerDesContext context) Builds an error using the operation's context-aware serializer. -
serializeStackTrace
Serializes a stack trace to a list of pipe-delimited strings in the formatclassName|methodName|fileName|lineNumber.- Parameters:
stackTrace- the stack trace elements to serialize- Returns:
- list of serialized stack trace strings
-
deserializeStackTrace
Deserializes a list of pipe-delimited strings back into stack trace elements.- Parameters:
stackTrace- the serialized stack trace strings- Returns:
- array of reconstructed StackTraceElements
-