-
Notifications
You must be signed in to change notification settings - Fork 27
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
Non standard return value of 'ok' in FromError() #180
Comments
Hey @wiegell, I believe there is a misconception on what the
|
Sorry i never replied. I saw that it's a pattern you inherited from the grpc package - right? Anyway i don't think thats intuitive either. In general i'm a fan of using |
Seems like something we could provide as well. Lay out exactly what you need and I see what I can do |
So many places errors are returned like this: I made an example of what i think is better when error matching is needed. What will be hard is if you want backwards compatibility with the current code system. Clone them to adjecent folders, since the example depends on The changes i've made to eventstore: IMO this way simplifies error matching. I would also encourage more error wrapping, since it can be confusing to get a raw grpc error from the esdb.Client, which happens sometimes. Uber also have some recommendations on wrapping: |
Normally you would expect ok to be true, if a type assertion is correct, see e.g.:
https://go.dev/tour/methods/15
However for the FromError method the return value is false, when the underlying type assertion is correct (from docs):
From source:
That's not intuitive and goes against what "ok" means in many other cases in go.
Changing this would ofc. be a breaking change
The text was updated successfully, but these errors were encountered: