summaryrefslogtreecommitdiffstats
path: root/models/error.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-12-16 05:57:34 +0800
committertechknowlogick <techknowlogick@gitea.io>2019-12-15 16:57:34 -0500
commit67b316a954b161cac27e16b6455837881919dd94 (patch)
tree46e0278f556447cd9228d63c49a32dacea1f3352 /models/error.go
parentc6b3c5bcefde6be4c64f5769a38962c2ce6ad6de (diff)
downloadgitea-67b316a954b161cac27e16b6455837881919dd94.tar.gz
gitea-67b316a954b161cac27e16b6455837881919dd94.zip
Refactor comment (#9330)
* Refactor comment * fix test * improve code
Diffstat (limited to 'models/error.go')
-rw-r--r--models/error.go32
1 files changed, 32 insertions, 0 deletions
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