diff options
author | Joe Chen <jc@unknwon.io> | 2022-11-27 15:53:26 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-27 15:53:26 +0800 |
commit | 44333afd20a6312b617e0c33a497a4385ba3a250 (patch) | |
tree | 08550527657f6af16fab8d42b863cda4c34da095 /internal/gitutil | |
parent | 13099a7e4fe7565bb858646d42d1fba817cb06cc (diff) |
chore: consistently use `errors.Cause` for identifying error types (#7264)
Diffstat (limited to 'internal/gitutil')
-rw-r--r-- | internal/gitutil/error.go | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/internal/gitutil/error.go b/internal/gitutil/error.go index 205546aa..a823dd72 100644 --- a/internal/gitutil/error.go +++ b/internal/gitutil/error.go @@ -6,6 +6,7 @@ package gitutil import ( "github.com/gogs/git-module" + "github.com/pkg/errors" "gogs.io/gogs/internal/errutil" ) @@ -27,17 +28,19 @@ func NewError(err error) error { return Error{error: err} } -// IsErrSubmoduleNotExist returns true if the error is git.ErrSubmoduleNotExist. +// IsErrSubmoduleNotExist returns true if the underlying error is +// git.ErrSubmoduleNotExist. func IsErrSubmoduleNotExist(err error) bool { - return err == git.ErrSubmoduleNotExist + return errors.Cause(err) == git.ErrSubmoduleNotExist } -// IsErrRevisionNotExist returns true if the error is git.ErrRevisionNotExist. +// IsErrRevisionNotExist returns true if the underlying error is +// git.ErrRevisionNotExist. func IsErrRevisionNotExist(err error) bool { - return err == git.ErrRevisionNotExist + return errors.Cause(err) == git.ErrRevisionNotExist } -// IsErrNoMergeBase returns true if the error is git.ErrNoMergeBase. +// IsErrNoMergeBase returns true if the underlying error is git.ErrNoMergeBase. func IsErrNoMergeBase(err error) bool { - return err == git.ErrNoMergeBase + return errors.Cause(err) == git.ErrNoMergeBase } |