-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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(errors.Is(err, ErrIgnorable)) // output = "true" fmt.Println(multierr.Every(err, ErrIgnorable)) // output = "false" err := multierr.Combine(ErrIgnorable, ErrIgnorable) fmt.Println(errors.Is(err, ErrIgnorable)) // output = "true" 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 #66.
- Loading branch information
Showing
3 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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