summaryrefslogtreecommitdiffstats
path: root/models/error.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/error.go')
-rw-r--r--models/error.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/models/error.go b/models/error.go
index c025437c50..9974287a0a 100644
--- a/models/error.go
+++ b/models/error.go
@@ -11,6 +11,21 @@ import (
"code.gitea.io/gitea/modules/git"
)
+// ErrNotExist represents a non-exist error.
+type ErrNotExist struct {
+ ID int64
+}
+
+// IsErrNotExist checks if an error is an ErrNotExist
+func IsErrNotExist(err error) bool {
+ _, ok := err.(ErrNotExist)
+ return ok
+}
+
+func (err ErrNotExist) Error() string {
+ return fmt.Sprintf("record does not exist [id: %d]", err.ID)
+}
+
// ErrNameReserved represents a "reserved name" error.
type ErrNameReserved struct {
Name string