What package do you use for creating error respons...
# random
ö
What package do you use for creating error responses from Lambda, if any?
r
What do you mean by 'error responses from lambda'?
ö
I mean to create error responses for 400's and 500's
for example,
http-errors
library
r
so API Gateway responses? We don't use a 3rd party library but we have a simple success/fail response builder we reuse across the API GW lambdas
a
return {“statusCode”: 400, “message”: “that broke”}
ö
but what if you had a Runtime error… undefined is not a function for example lol
g
our top level lambda has a try/catch - then the caught error just returns similar to what Alex wrote above - and we just log the error in the console so can check what happened
ö
i see
r
Yeah, we have handleCaughtError and handleUncaughtError functions to deal with 'expected' errors and unexpected ones