mirror of
https://github.com/go-gitea/gitea
synced 2025-07-03 09:07:19 +00:00
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
This commit is contained in:
committed by
Lunny Xiao
parent
2ef33b5338
commit
30787e48f2
@ -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
|
||||
|
Reference in New Issue
Block a user