-
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
Catch errors in metrics #173
Comments
@thadeuk Lambda API catches thrown errors and returns them as a "custom response" with an HTTP 500 status code, instead of crashing the lambda. There are drawbacks to letting your lambda fail for most of these errors. Check out my response to a similar issue here: #171 (comment) Let me know, if you have any suggestions or other concerns. |
@stawecki I was using your method 3 (a), I've added a throw in middleware error function. I was trying to get the error as a 500 HTTP code with the throw message in it, instead of a generic message, but it seems I have to deal with it in another way. Anyway, thanks for sharing your response. |
@thadeuk I haven't found any way so far and it doesn't seem like there is. If you look at AWS docs - Handle Lambda errors in API Gateway it states:
Also when editing the API in AWS panel, the "standard error" configuration found in "integration response" is disabled for Lambda proxy, so it seems returning a custom error inside a successful lambda execution is the only way to avoid the generic 502 (when using Lambda proxy, which Lambda API relies on). Since this is the only way API Gateway expects the lambda to respond, it makes sense that on failure it doesn't pass any further information to the client. |
I notice that api errors are not counted as errors in Cloudwatch metrics. I tested it also in Epsagon and it shows
success
even for functions that throw.I've tried to get an error with the following code, they all return the correct HTTP code and message, but metrics does not catch them.
I have no middleware for errors.
The text was updated successfully, but these errors were encountered: