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

Errors appear to be reversed #558

Open
calummoore opened this issue Mar 8, 2023 · 3 comments
Open

Errors appear to be reversed #558

calummoore opened this issue Mar 8, 2023 · 3 comments

Comments

@calummoore
Copy link

calummoore commented Mar 8, 2023

Environment

0.30.0

Steps to Reproduce

  1. Create multiple wrapped errors using thiserror::Error: e.g. OuterError::HTTPError(InnerError::CollectionHasNoAST)
  2. Call sentry::capture_error(&error);
  3. View in Sentry console

Expected Result

Errors go from more specific (lower/inner) to more vague (higher/outer)

CollectionHasNoAST -> HTTPError

Actual Result

HTTPError -> CollectionHasNoAST

Console

Screenshot 2023-03-08 at 00 35 39

Workaround

I currently reverse the errors back, and now errors make sense in the console:

let mut e = sentry::event_from_error(err);
// Reverse the errors
e.exception.values.reverse();
sentry::capture_event(e);
@Swatinem
Copy link
Member

Swatinem commented Mar 8, 2023

I believe you are right!
The docs are a bit vague on how this should be handled: https://develop.sentry.dev/sdk/event-payloads/exception/

Multiple values represent chained exceptions and should be sorted oldest to newest.

I will double-check with the rest of the SDK team to find a definitive answer.

@Swatinem
Copy link
Member

Checking with other SDKs, this seems to be consistent at least with the Python SDK, which is more of a reference SDK than the Rust one.

No matter which way chained errors are sorted, they will still group into individual issues for each unique chain, which is good.
The problem is that neither sorting direction is particularly useful.

You either end up with your catch-all anyhow::Error as the label in sentry;
Or you end up with io::Error which I bet is a very common leaf error.

Neither of these two options is useful. :-(

@calummoore
Copy link
Author

io::Error is definitely more useful than anyhow::Error. And if the user wants something more useful that io:Error they can wrap it in a struct CannotReadSomething(io::Error) and unless they add it as source it won't be the last item CannotReadSomething would be.

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