mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-01 14:44:35 -04: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:
parent
2ef33b5338
commit
30787e48f2
7 changed files with 26 additions and 12 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue