Support multierr.Every#78
Merged
JacobOaks merged 3 commits intouber-go:masterfrom Mar 28, 2023
Merged
Conversation
This PR introduces a new exported function in the multierr package
called `Every`, which checks every error within a given error
against a given target using `errors.Is`, and only returns true if
all checks return true.
```go
err := multierr.Combine(ErrIgnorable, errors.New("great sadness"))
fmt.Println(multierr.Every(err, ErrIgnorable))
// output = "false"
err := multierr.Combine(ErrIgnorable, ErrIgnorable)
fmt.Println(multierr.Every(err, ErrIgnorable)
// output = "true"
```
This also works when the error passed in as the first argument is not a `multiErr`,
including when it is a go1.20+ error that implements `Unwrap() []error`.
This solves uber-go#66.
r-hang
approved these changes
Mar 28, 2023
| wantEvery: false, | ||
| }, | ||
| { | ||
| desc: "multiErr w multiErr target", |
sywhang
reviewed
Mar 28, 2023
Codecov Report
@@ Coverage Diff @@
## master #78 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 3 3
Lines 117 120 +3
=========================================
+ Hits 117 120 +3
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
sywhang
approved these changes
Mar 28, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces a new exported function in the multierr package called
Every, which checks every error within a given error against a given target usingerrors.Is, and only returns true if all checks return true.This also works when the error passed in as the first argument is not a
multiErr, including when it is a go1.20+ error that implementsUnwrap() []error.This solves #66.