Handling Exceptions - Serverless Architectures with AWS Lambda

Handling Exceptions

You might decide to throw and handle exceptions differently depending on your use case for Lambda. If you’re placing an API Gateway API in front of a Lambda function, you may decide to throw an exception back to API Gateway where it might be transformed, based on its contents, into the appropriate HTTP status code and message for the error that occurred. If you’re building an asynchronous data processing system, you might decide that some exceptions within your code base should equate to the invocation moving to the dead letter queue for reprocessing, while other errors can just be logged and not placed on the dead letter queue. You should evaluate what your decide failure behaviors are and ensure that you are creating and throwing the correct types of exceptions within your code to achieve that behavior. To learn more about handling exceptions, see the following for details about how exceptions are defined for each language runtime environment: