Hi team,
I used this answer to exit my lambda when an error occur in Redis connect (Thank you @Indranil Banerjee AWS for your answer)
https://repost.aws/questions/QURgqZS0xaQcmfI0PkfT-4QA/handle-errors-in-lambda-hapening-on-the-init-phase
as my code ins in node js/javaScript not python I used process.exit()
instead of sys.exit()
but my lambda still fails with a generated error and I can't return back my error response :
return {
statusCode:"500",
headers: {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*",
},
body: JSON.stringify(MyresponseErrorObject),
};
if I do my return
return {
statusCode:"500",
headers: {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*",
},
body: JSON.stringify(MyresponseErrorObject),
};
after process.exit()
it will be unreachable code.
is process.exit()
the right way to exit lambda function in nodeJs (like sys.exit() in python) ?
my lambda still fails as shown in the screenshot above(this is a simulated error I made a mistake on the Redis URL so I can simulate the error and handle it properly outside the event handler code)
appreciate your help on this.
Thank you!