-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to cause error in Lambda? #171
Comments
This is an interesting issue, as there are a couple of things to consider: 1. What kind of errors you want to see as Lambda errors?For example 2. How Lambda errors are handled by API Gateway?Consider the following lambda:
If you do a test run, you should see: "Execution result: succeeded"
You've created an error response, but the Lambda itself hasn't experienced an error.
Test returns: "Execution result: failed" and API Gateway returns:
One thing to notice is that any information from the thrown error object are hidden from the user, but will be visible on CloudWatch. In case of an HTTP error like 403/404, I don't believe there is a way to return those to API Gateway while also causing an actual Lambda error, without API Gateway sending the client a 502 instead (there may be some REST API configuration to achieve this that I'm not aware of). From that perspective, it seems safest for Lambda API to simply handle all errors and return an error response (code responsible for doing this: https://github.com/jeremydaly/lambda-api/blob/master/index.js#L252-L313). 3. How to best monitor different kinds of errors?As I mentioned in my first point, it might not be a good idea to treat every error as a Lambda error, since it's a blunt tool when you want to separate the 4xx from the 5xx. a) Throw 5xx errors as Lambda errors
This is not ideal as you want the original error and its stack trace. Maybe someone else have managed to get around it. You'd have to log the actual b) Instead of using Lambda errors, use Lambda Insights.
If you've found an invocation that interests you, fetch the full log by requestId:
|
Whereas Yeah, I think my ask boils down to if I could have the error not caught by this package. I think I lose the ability to see Lambda errors (as shown in the picture in the description) and all Lambdas would lose the ability to have Thank you for the thoughful response. |
To take advantage of monitoring and on error events in Lambda, I can't seem to cause anything to show a Lamba error.
Could we talk through how to accomplish this with the projects example?
I've tried these:
The text was updated successfully, but these errors were encountered: