diff --git a/retry/retry.go b/retry/retry.go index 788d72e..69be3a9 100644 --- a/retry/retry.go +++ b/retry/retry.go @@ -91,7 +91,13 @@ func (e *ErrorSet) Is(err error) bool { e.mu.Lock() defer e.mu.Unlock() - return len(e.errs) == 1 && errors.Is(e.errs[0], err) + for _, ee := range e.errs { + if errors.Is(ee, err) { + return true + } + } + + return false } // TimeoutError represents a timeout error. diff --git a/retry/retry_test.go b/retry/retry_test.go index 37a4baf..86a8e47 100644 --- a/retry/retry_test.go +++ b/retry/retry_test.go @@ -130,6 +130,12 @@ func Test_errors(t *testing.T) { t.Fatal("error set should wrap errors") } + errSet.Append(errors.New("foo")) + + if !errors.Is(&errSet, e) { + t.Fatal("error set should wrap errors") + } + errSet = ErrorSet{} errSet.Append(UnexpectedError(e))