diff options
author | Antoine GIRARD <sapk@users.noreply.github.com> | 2017-07-06 15:30:19 +0200 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-07-06 21:30:19 +0800 |
commit | 30787e48f219b23701f660ba0b99b326ab82e997 (patch) | |
tree | 005dfef495149e81e78ad31c251cc3a3e2709870 /models/org.go | |
parent | 2ef33b53381f68dc2af88eabfe5f35c3dbc94412 (diff) | |
download | gitea-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/org.go')
-rw-r--r-- | models/org.go | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/models/org.go b/models/org.go index b4cbabcb53..d43f15f9aa 100644 --- a/models/org.go +++ b/models/org.go @@ -16,8 +16,6 @@ import ( ) var ( - // ErrOrgNotExist organization does not exist - ErrOrgNotExist = errors.New("Organization does not exist") // ErrTeamNotExist team does not exist ErrTeamNotExist = errors.New("Team does not exist") ) @@ -180,7 +178,7 @@ func CreateOrganization(org, owner *User) (err error) { // GetOrgByName returns organization by given name. func GetOrgByName(name string) (*User, error) { if len(name) == 0 { - return nil, ErrOrgNotExist + return nil, ErrOrgNotExist{0, name} } u := &User{ LowerName: strings.ToLower(name), @@ -190,7 +188,7 @@ func GetOrgByName(name string) (*User, error) { if err != nil { return nil, err } else if !has { - return nil, ErrOrgNotExist + return nil, ErrOrgNotExist{0, name} } return u, nil } |