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

Support automatic tagging of errors with location? #278

Closed
kevinushey opened this issue Oct 20, 2022 · 1 comment
Closed

Support automatic tagging of errors with location? #278

kevinushey opened this issue Oct 20, 2022 · 1 comment

Comments

@kevinushey
Copy link

This is somewhat related to the existing backtrace support. For user-facing application logs, it's useful to log two locations:

  1. Where the error itself was logged,
  2. Where the error object itself was created.

Right now, the second point is caught in the backtrace, but it'd be useful if we could pull out just the location where the error object itself was constructed (as opposed to the whole stack).

There was some discussion in #22 around handling this is user code via e.g. an extension trait, but it would be helpful if this could be part of the default behavior -- that is, any error object converted to anyhow::Result<> via ? could automatically be tagged with an error location (if backtraces are enabled), and users could decide whether to include that error location when logging those errors.

(In theory, users of anyhow could post-process the backtrace message and figure out which line is relevant, but I'm hoping there's some tooling in the backtrace crate that would make it easier to do when the trace itself is constructed.)

@dtolnay
Copy link
Owner

dtolnay commented Nov 6, 2022

Duplicate of #139.

@dtolnay dtolnay closed this as completed Nov 6, 2022
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

No branches or pull requests

2 participants