I am using aws lambda proxy integration.
I hit the API in response if Success means 200 response is coming if error means 500 error is coming correct.
{
try:
return {
"statusCode": str(200),
"body": json.dumps("Hello"),
"headers": headers,
}
except Exception as e:
return {
"statusCode": str(500),
"body": json.dumps("Error"),
"headers": headers,
}
}
But when I am trying to return the exception from another method inside the lambda in a postman error response is coming, but statuscode is 200 response is there. Below is the code.
def getMethod(val):
try:
a= val
return {
"statusCode": str(200),
"body": json.dumps("Success"),
"headers": headers,
}
except Exception as e:
return {
"statusCode": str(500),
"body": json.dumps("Error in getMethod"),
"headers": headers,
}
handler request(event,context):
try:
response = getMethod(
return {
"statusCode": str(200),
"body": json.dumps(response),
"headers": headers,
}
except Exception as e:
return {
"statusCode": str(500),
"body": json.dumps("Error"),
"headers": headers,
}