-
Notifications
You must be signed in to change notification settings - Fork 18k
proposal: errors: Is(err, target) should allow err to decide even when target is nil #39167
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
Comments
See: https://github.com/rocketlaunchr/dataframe-go/blob/master/error_collection.go#L11 type ErrorCollection struct {
errors []error
} The proposal suggests that It is feasible that when the error collection holds no errors, it would like to allow the user to write: ec := NewErrorCollection()
isNil := errors.Is(ec, nil) where But due to the implementation of |
The documetation currently states:
Due to the phrasing, the current proposal is still consistent with the documentation and arguably should not be deemed to breach Go1 backward compatibility guarantees (as it could be interpreted as a bug). |
The predeclared type |
Absolutely. It would be very unfortunate if we permitted err != nil && errors.Is(err, nil) == true. |
This proposal has been added to the active column of the proposals project |
The essence of this behaviour can be achieved by defining an |
Based on the discussion above, this proposal seems like a likely decline. |
No change in consensus, so declined. |
Currently
Is
looks like this:See:
https://golang.org/src/errors/wrap.go?s=1170:1201#L29 and also
https://github.com/golang/xerrors/blob/master/wrap.go#L50
The text was updated successfully, but these errors were encountered: