We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Problem The code looks redundant and cumbersome in cases when you need to check an error match several times. Example:
func foo() { err := bar() if errors.Is(err, err1) || errors.Is(err, err2) || errors.Is(err, err3) { // some logic } }
Solution A new function that will allow you to check for errors like this:
func foo() { err := bar() if errors.In(err, err1, err2, err3) { // some logic } }
Implementation
package errors func In(err error, target ...error) bool { for _, v := range target { if errors.Is(err, v) { return true } } return false }
The text was updated successfully, but these errors were encountered:
Related Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Sorry, something went wrong.
I don't think it's a very common thing to do: https://github.com/search?q=language%3AGo+%2F%28errors.Is.*%5C%7C%5C%7C%29%2B%2F&type=code
How about
// Match returns the matched error in targets for err. func Match(err error, targets ...error) error
?
No branches or pull requests
Proposal Details
Problem
The code looks redundant and cumbersome in cases when you need to check an error match several times. Example:
Solution
A new function that will allow you to check for errors like this:
Implementation
The text was updated successfully, but these errors were encountered: