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
xerrors: allow accessing the frame for each error directly #30038
Comments
Right now we don't want to expose the internal representation and commit to one particular implementation. Maybe later, once we have more experience with all of this. |
@rsc where does this leave the issue? Did you mean to keep it open? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@nhooyr I was just about to write the same string parsing code to handle this. Would you mind sharing yours? Our use case is sending the stack trace as structured metadata to Sentry. |
In case anyone stumbles upon this issue. I came up with the following, fragile, implementation:
I included a test in my code to catch changes to the formatting. |
I also faced this problem trying to send my errors to Rollbar. It looks for interface, to build trace chain:
Sadly - it seems to be possible only with custom errors. |
Sorry for the delay @jszwedko My code for it is at https://github.com/cdr/slog/blob/180f0e6b153d97782ef73d7571b54aff674db661/map.go#L139 |
When using structured logging with errors, we don't want a string representation of the error + the frame, we want to access the error string, function name and file:line separately to make them separate fields in the UI and to make it easier to analyze logs. For now, I've written an
xerrors.printer
that just stores all lines that are printed to it and then returns those and based onxerrors
atm, the first line is the error message, second is the function and third is the file name. But this is janky and fragile.An easy way to do this is to add an interface to the package that errors can implement to return their frames.
The text was updated successfully, but these errors were encountered: