bref icon indicating copy to clipboard operation
bref copied to clipboard

Log error location

Open theoboldalex opened this issue 2 years ago • 2 comments

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 avatar Sep 04 '23 12:09 theoboldalex

Any feedback on this appreciated @mnapoli

theoboldalex avatar Nov 20 '23 08:11 theoboldalex

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 avatar Nov 20 '23 09:11 mnapoli

Closing inactive PRs, feel free to reopen.

mnapoli avatar Mar 19 '24 14:03 mnapoli