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

Wrapped multi-errors should implement Unwrap() []error #38

Open
abhinav opened this issue Nov 28, 2023 · 1 comment
Open

Wrapped multi-errors should implement Unwrap() []error #38

abhinav opened this issue Nov 28, 2023 · 1 comment

Comments

@abhinav
Copy link
Contributor

abhinav commented Nov 28, 2023

errtrace errors only implement Unwrap() error right now.
This hides the actual list of errors for wrapped multi-errors.
We need to implement Unwrap() []error if the error we're wrapping is a multi-error.

Alternatively, we can always implement only Unwrap() []error, and things should still just work.

@abhinav
Copy link
Contributor Author

abhinav commented Nov 28, 2023

This hides the actual list of errors for wrapped multi-errors.

Actually, this isn't quite right. Even with just Unwrap() error, we're exposing the underlying list on the "next" layer, so it's not entirely inaccessible. But it's still going to be annoying. Although I'm not entirely certain that implementing Unwrap() []error is the right choice there, because transparently skipping the actual wrapped error means fmt.Errorf("information: %w %w", a, b) will unpack to a and b, ignoring information entirely.

Separately, maybe we also need an errtrace.Unwrap that's a drop-in replacement for errors.Unwrap, and all it does is transparently unwrap the top-level errtrace error—if any. That can be a separate discussion.

@abhinav abhinav changed the title Wrapped multi-errors should implement Unwrap() []error Add errtrace.Unwrap() function as drop-in for errors.Unwrap Nov 29, 2023
@abhinav abhinav changed the title Add errtrace.Unwrap() function as drop-in for errors.Unwrap Wrapped multi-errors should implement Unwrap() []error Nov 29, 2023
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

1 participant