From 44333afd20a6312b617e0c33a497a4385ba3a250 Mon Sep 17 00:00:00 2001 From: Joe Chen Date: Sun, 27 Nov 2022 15:53:26 +0800 Subject: chore: consistently use `errors.Cause` for identifying error types (#7264) --- internal/gitutil/error.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'internal/gitutil') 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 } -- cgit v1.2.3