diff --git a/common/baderror/baderror.go b/common/baderror/baderror.go index c5ab530..d90ddeb 100644 --- a/common/baderror/baderror.go +++ b/common/baderror/baderror.go @@ -2,11 +2,10 @@ package baderror import ( "context" + "errors" "io" "net" "strings" - - E "github.com/sagernet/sing/common/exceptions" ) func Contains(err error, msgList ...string) bool { @@ -22,8 +21,7 @@ func WrapH2(err error) error { if err == nil { return nil } - err = E.Unwrap(err) - if err == io.ErrUnexpectedEOF { + if errors.Is(err, io.ErrUnexpectedEOF) { return io.EOF } if Contains(err, "client disconnected", "body closed by handler", "response body closed", "; CANCEL") { diff --git a/common/exceptions/inner.go b/common/exceptions/inner.go index 3799af9..58bcc5a 100644 --- a/common/exceptions/inner.go +++ b/common/exceptions/inner.go @@ -1,24 +1,14 @@ package exceptions -import "github.com/sagernet/sing/common" +import ( + "errors" -type HasInnerError interface { - Unwrap() error -} + "github.com/sagernet/sing/common" +) +// Deprecated: Use errors.Unwrap instead. func Unwrap(err error) error { - for { - inner, ok := err.(HasInnerError) - if !ok { - break - } - innerErr := inner.Unwrap() - if innerErr == nil { - break - } - err = innerErr - } - return err + return errors.Unwrap(err) } func Cast[T any](err error) (T, bool) { diff --git a/common/exceptions/multi.go b/common/exceptions/multi.go index 2cdec05..78fb3b6 100644 --- a/common/exceptions/multi.go +++ b/common/exceptions/multi.go @@ -63,12 +63,5 @@ func IsMulti(err error, targetList ...error) bool { return true } } - err = Unwrap(err) - multiErr, isMulti := err.(MultiError) - if !isMulti { - return false - } - return common.All(multiErr.Unwrap(), func(it error) bool { - return IsMulti(it, targetList...) - }) + return false }