chore: Remove unused code in errors package (#62996)

This commit is contained in:
Varun Gandhi 2024-05-31 21:56:42 +08:00 committed by GitHub
parent 9b2d8f9be1
commit 9a75701c59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 0 additions and 19 deletions

View File

@ -35,13 +35,6 @@ func Ignore(err error, pred ErrorPredicate) error {
// ErrorPredicate is a function type that returns whether an error matches a given condition
type ErrorPredicate func(error) bool
// HasTypePred returns an ErrorPredicate that returns true for errors that unwrap to an error with the same type as target
func HasTypePred(target error) ErrorPredicate {
return func(err error) bool {
return HasType(err, target)
}
}
// IsPred returns an ErrorPredicate that returns true for errors that uwrap to the target error
func IsPred(target error) ErrorPredicate {
return func(err error) bool {
@ -56,7 +49,3 @@ func IsContextCanceled(err error) bool {
func IsDeadlineExceeded(err error) bool {
return Is(err, context.DeadlineExceeded)
}
func IsContextError(err error) bool {
return IsAny(err, context.Canceled, context.DeadlineExceeded)
}

View File

@ -13,7 +13,6 @@ func (t *testError) Error() string { return "testError" }
func TestIgnore(t *testing.T) {
testError1 := New("test1")
testError2 := New("test2")
testError3 := &testError{}
cases := []struct {
input error
@ -51,13 +50,6 @@ func TestIgnore(t *testing.T) {
check: func(t *testing.T, err error) {
require.NoError(t, err)
},
}, {
input: Append(testError1, testError3),
pred: HasTypePred(testError3),
check: func(t *testing.T, err error) {
require.ErrorIs(t, err, testError1)
require.False(t, HasType(err, testError3))
},
}, {
input: Wrap(Append(testError1, testError2), "wrapped"),
pred: IsPred(testError1),