From 67b316a954b161cac27e16b6455837881919dd94 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 16 Dec 2019 05:57:34 +0800 Subject: Refactor comment (#9330) * Refactor comment * fix test * improve code --- models/error.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'models/error.go') diff --git a/models/error.go b/models/error.go index 16be512139..a17ff5f9d0 100644 --- a/models/error.go +++ b/models/error.go @@ -1121,6 +1121,38 @@ func (err ErrNewIssueInsert) Error() string { return err.OriginalError.Error() } +// ErrIssueWasClosed is used when close a closed issue +type ErrIssueWasClosed struct { + ID int64 + Index int64 +} + +// IsErrIssueWasClosed checks if an error is a ErrIssueWasClosed. +func IsErrIssueWasClosed(err error) bool { + _, ok := err.(ErrIssueWasClosed) + return ok +} + +func (err ErrIssueWasClosed) Error() string { + return fmt.Sprintf("Issue [%d] %d was already closed", err.ID, err.Index) +} + +// ErrPullWasClosed is used close a closed pull request +type ErrPullWasClosed struct { + ID int64 + Index int64 +} + +// IsErrPullWasClosed checks if an error is a ErrErrPullWasClosed. +func IsErrPullWasClosed(err error) bool { + _, ok := err.(ErrPullWasClosed) + return ok +} + +func (err ErrPullWasClosed) Error() string { + return fmt.Sprintf("Pull request [%d] %d was already closed", err.ID, err.Index) +} + // ErrForbiddenIssueReaction is used when a forbidden reaction was try to created type ErrForbiddenIssueReaction struct { Reaction string -- cgit v1.2.3