Skip to content Skip to sidebar Skip to footer

Handling Errors In Aws Lambda Function With Api Gateway

Every time I have a syntax error or I just want to send a custom error in my AWS Lambda function, I get the same 502 Bad Gateway response (Internal server error). I tried that simp

Solution 1:

If you use integration: lambda-proxy, you need to return a proper error response from your Lambda, not from API Gateway.

In this case, you can use what already tried:

callback(null, { body: JSON.stringify( { errorMessage: "my error" })

I thought we can use the first argument to send errors

You can, if you use integration: lambda in your serverless.yml but in your case, you're not.

Post a Comment for "Handling Errors In Aws Lambda Function With Api Gateway"