Skip to content

Commit d9f20d7

Browse files
committed
fix(errors.Is): fix errors.Is(oopsErr, oopsErr)
1 parent 5481e50 commit d9f20d7

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

error.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ func (o OopsError) Unwrap() error {
8585
// Is checks if this error matches the target error.
8686
// This method implements the errors.Is interface for error comparison.
8787
func (o OopsError) Is(err error) bool {
88+
if _, ok := err.(OopsError); ok {
89+
return true
90+
}
91+
8892
return errors.Is(o.err, err)
8993
}
9094

error_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ func TestErrorsIs(t *testing.T) {
1717
err = Wrap(fs.ErrExist)
1818
is.ErrorIs(err, fs.ErrExist)
1919

20+
err = Wrap(fs.ErrExist)
21+
is.ErrorIs(err, err)
22+
2023
err = Wrapf(fs.ErrExist, "Error: %w", assert.AnError)
2124
is.ErrorIs(err, fs.ErrExist)
2225

0 commit comments

Comments
 (0)