As discussed on gitter, the plan is to implement the error handling as a two-stage process.
- Add an
additionalCodes
property to theerror
object passed in as the third argument to the api handler. This will specify the additional error responses that should be setup by API Gateway, and the associated regexes. - Create a new
claudia-api-errors
module, which will allow developers to throw a predefined set ofError
objects, which will correspond to response codes.
Only 1. needs to be implemented to allow multiple error responses, 2. is more of a nice-to-have.
API Gateway allows you to parse the error message returned from a lambda function, and apply a response code according to a regex that you configure. Here's a good primer on how this works.