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

Error details that created with errors.NewWithDetails are lost after it combined using errors.Combine #26

Open
dimasdanz opened this issue Jan 26, 2022 · 1 comment

Comments

@dimasdanz
Copy link

Code to reproduce

errWithDetail := errors.NewWithDetails(
 "errorMessage",
  "key", "value",
)
errOther := errors.New("Something")

errors.GetDetails(errWithDetail) // [key, value] -> detail exists
errors.GetDetails(errors.Combine(errWithDetail, errOther) // [] -> prints empty slice

// also happened here
errors.Append(errWithDetail, errOther) // []

Is this expected?

@sagikazarmark
Copy link
Member

Good question...I'd say yeah, this makes sense. Not returning details is somewhat easier than resolving potentially conflicting ones.

Also, returning multiple errors should be relatively rare, so in those cases you might want to unpack errors and handle them separately. If you use an error handler, you could actually implement a middleware that unpacks these errors for you and passes them to the underlying handler one by one.

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