Skip to content
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

Log error location #1635

Closed
wants to merge 8 commits into from

Conversation

theoboldalex
Copy link
Contributor

@theoboldalex theoboldalex commented Sep 4, 2023

resolves #1619

So that we can see the context of an error in Cloudwatch logs, I have added an errorLocation key to the errorFormatted data structure. This means that the file and line number where the exception is thrown is logged.

@theoboldalex
Copy link
Contributor Author

Any feedback on this appreciated @mnapoli

@mnapoli
Copy link
Member

mnapoli commented Nov 20, 2023

I'm sorry, while reviewing this I'm realizing this object follows a structure defined by AWS Lambda: https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html#runtimes-api-invokeerror

Screen-001433

I apologize for not spotting that sooner 🤦

I'm thinking of 3 options:

  1. adding the extra errorLocation (current state of the PR) if it doesn't break error reporting and that new field shows up in the CloudWatch logs
  2. adding the file + line in the stack trace (insert it as the first line?
  3. adding the file + line to the error message

For reference, here's what PHP logs in case of an uncaught exception:

Screen-001434

Note: I don't think it's a good reference though because it's an "Uncaught exception" line that is a fatal error. In our case it's not exactly that, exceptions are OK (to communicate errors to Lambda), so we don't necessarily want to copy that format.

I think the 1st option is the best, but that requires testing on Lambda to confirm the behavior works as expected.

@mnapoli
Copy link
Member

mnapoli commented Mar 19, 2024

Closing inactive PRs, feel free to reopen.

@mnapoli mnapoli closed this Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include the file + line number in the Lambda failure logs
2 participants