mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 14:11:44 +00:00
chore: Remove unused code in errors package (#62996)
This commit is contained in:
parent
9b2d8f9be1
commit
9a75701c59
@ -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)
|
||||
}
|
||||
|
||||
@ -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),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user