Custom error message

lambda
api-gateway

#1

i’m looking for ways to return error messages on the API with lambda integration (not lambda-proxy integration) and want to eliminate errorStackTrace when using:

callback(new Error('[400] Something is wrong here'))

and want to return something like the response below and get a 400 Bad Request header in Postman:

{
   message: "Something is wrong here"
}

How do you guys do it?


#2

Have you tried adding a response template for the 400 status code? https://serverless.com/framework/docs/providers/aws/events/apigateway/#responses