summaryrefslogtreecommitdiffstats
path: root/models/error.go
diff options
context:
space:
mode:
authorAntoine GIRARD <sapk@users.noreply.github.com>2017-07-06 15:30:19 +0200
committerLunny Xiao <xiaolunwen@gmail.com>2017-07-06 21:30:19 +0800
commit30787e48f219b23701f660ba0b99b326ab82e997 (patch)
tree005dfef495149e81e78ad31c251cc3a3e2709870 /models/error.go
parent2ef33b53381f68dc2af88eabfe5f35c3dbc94412 (diff)
downloadgitea-30787e48f219b23701f660ba0b99b326ab82e997.tar.gz
gitea-30787e48f219b23701f660ba0b99b326ab82e997.zip
Improve org error handling (#2117)
* Improve ErrOrgNotExist type Return new error type Use good error check Use new method to check error Update tests * Fix unchanged method name report
Diffstat (limited to 'models/error.go')
-rw-r--r--models/error.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/models/error.go b/models/error.go
index 404939c58a..74551ad8f7 100644
--- a/models/error.go
+++ b/models/error.go
@@ -448,6 +448,22 @@ func (err ErrAccessTokenEmpty) Error() string {
// \_______ /__| \___ (____ /___| /__/_____ \(____ /__| |__|\____/|___| /
// \/ /_____/ \/ \/ \/ \/ \/
+// ErrOrgNotExist represents a "OrgNotExist" kind of error.
+type ErrOrgNotExist struct {
+ ID int64
+ Name string
+}
+
+// IsErrOrgNotExist checks if an error is a ErrOrgNotExist.
+func IsErrOrgNotExist(err error) bool {
+ _, ok := err.(ErrOrgNotExist)
+ return ok
+}
+
+func (err ErrOrgNotExist) Error() string {
+ return fmt.Sprintf("org does not exist [id: %d, name: %s]", err.ID, err.Name)
+}
+
// ErrLastOrgOwner represents a "LastOrgOwner" kind of error.
type ErrLastOrgOwner struct {
UID int64