codecentric / serverless-astra-graalvm

Sample serverless order processing API using DataStax Astra Serverless and AWS Lambda.
1 stars 1 forks source link

Proper error handling/logging #14

Closed rafaroca closed 2 years ago

rafaroca commented 2 years ago

The LambdaHandler throws an exception when the POSTed order is not valid. Since the exception is never caught, the exception message never surfaces anywhere in the logs. The API Gateway returns 500 Server Error.

This should instead give the user a proper 400 code and a message what is wrong with the request.

rafaroca commented 2 years ago

@FRosner I am trying to return a LambdaResponse which fits to the documentation. I cannot get far though, as my exception is not caught. The JVM seems to exit before the catch clause is executed at LambdaHandler:62. Do you have any clue why there is no log output from the logger inside the catch? I can't fathom why there's nothing in CloudWatch. Every RuntimeException should hit the catch clause, right?

rafaroca commented 2 years ago

After reading the CloudWatch output once again, it became clear: Task timed out after 3.00 seconds. Well, there's my problem. Increasing the timeout to 30s, it reveals a proper error message.

rafaroca commented 2 years ago

There is a generic 400 error message now. I'd leave it for this. If you would rather have a fully fledged verification of the Order, then we can open another ticket :)

FRosner commented 2 years ago

Thanks @rafaroca!