Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Unified Diff: common/errors/multierror.go

Issue 1863973002: LogDog: Update to archival V2. (Closed) Base URL: https://github.com/luci/luci-go@grpcutil-errors
Patch Set: Fix proto comment. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « common/api/logdog_coordinator/services/v1/util.go ('k') | common/errors/multierror_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/errors/multierror.go
diff --git a/common/errors/multierror.go b/common/errors/multierror.go
index 73d9597cfd0802d286b3853170c1c33e97c76dbe..3340a96e2a9670429fccde0225339486a6422145 100644
--- a/common/errors/multierror.go
+++ b/common/errors/multierror.go
@@ -94,3 +94,25 @@ func Fix(err error) error {
}
return err
}
+
+// Any returns true if a the filter function is true for the supplied error.
+// If the supplied error is a MultiError, Any will recurse into it.
+//
+// If err is nil, Any will return false.
+func Any(err error, fn func(error) bool) bool {
+ if err == nil {
+ return false
+ }
+
+ if fn(err) {
+ return true
+ }
+ if merr, ok := err.(MultiError); ok {
+ for _, e := range merr {
+ if Any(e, fn) {
+ return true
+ }
+ }
+ }
+ return false
+}
« no previous file with comments | « common/api/logdog_coordinator/services/v1/util.go ('k') | common/errors/multierror_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698