Class ExceptionHelper

java.lang.Object
software.amazon.lambda.durable.util.ExceptionHelper

public class ExceptionHelper extends Object
Utility class for handling exceptions
  • Constructor Details

    • ExceptionHelper

      public ExceptionHelper()
  • Method Details

    • sneakyThrow

      public static <T extends Throwable> void sneakyThrow(Throwable exception) throws T
      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

      public static Throwable unwrapCompletableFuture(Throwable throwable)
      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

      public static List<String> serializeStackTrace(StackTraceElement[] stackTrace)
    • deserializeStackTrace

      public static StackTraceElement[] deserializeStackTrace(List<String> stackTrace)