-
-
Notifications
You must be signed in to change notification settings - Fork 364
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
Replace pkg/errors with standard Go 1.13 error wrapping. #438
Comments
Yeah, I think |
About stack traces: I also ran into issues with that because we're using a different stacktrace library, and it wasn't picking up fosite's. Do you think it'd be possible to allow the user to customize which stacktracer is used? Something like
that would save that func in a global variable inside fosite, and all the places in fosite that want to wrap an error with a stack trace would call that. Another advantage would be that users that don't want stacktraces (for performance) can do that too. |
Hm, I also prefer keeping stack trace around. I am using a custom function which inspects if something is |
Typically one would solve that with an interface / type assertion in Go and it would be expected for the downstream code to be able to handle that, not upstream. |
So in #479 I changed that we now everywhere use Does this satisfy your needs @Dirbaio? Can you test? |
I think it does! :) |
Describe the bug
Fosite uses pkg/errors throughout the code to find the cause of errors. The issue is that
errors.Cause
does not unwrap errors wrapped in Go 1.13 style (Unwrap
method), just the ones in custom pkg/errors style (Cause
method). The maintainers have found that unwrapping both causes breaking changes, so they (understandably) have no plans to add that. See issue.Additionally, the pkg/errors package is in maintenance mode, as stated in their readme.
To Reproduce
One example on where this can result in uninituitive behavior:
fosite.Store
method, returnfosite.ErrNotFound
, but somehow wrapped with a Go 1.13-compliant wrapper (maybe some extra context, maybe a library that attaches stack traces to the errors...)errors.Cause(err) == fosite.ErrNotFound
.errors.Cause(err)
will not return thefosite.ErrNotFound
because it can't unwrap "through" the Go1.13 wrapping. The check will fail.Ideally fosite should use Go 1.13 wrapping, because that's what the entire ecosystem is moving to. Of course that would be a breaking change but in my opinion it's worth doing pre-1.0 while you still can?
The text was updated successfully, but these errors were encountered: