mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-30 05:50:50 +01:00
248 lines
6.1 KiB
Go
248 lines
6.1 KiB
Go
// Copyright 2015 The Gogs Authors. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package models
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
type ErrNameReserved struct {
|
|
Name string
|
|
}
|
|
|
|
func IsErrNameReserved(err error) bool {
|
|
_, ok := err.(ErrNameReserved)
|
|
return ok
|
|
}
|
|
|
|
func (err ErrNameReserved) Error() string {
|
|
return fmt.Sprintf("name is reserved: [name: %s]", err.Name)
|
|
}
|
|
|
|
type ErrNamePatternNotAllowed struct {
|
|
Pattern string
|
|
}
|
|
|
|
func IsErrNamePatternNotAllowed(err error) bool {
|
|
_, ok := err.(ErrNamePatternNotAllowed)
|
|
return ok
|
|
}
|
|
|
|
func (err ErrNamePatternNotAllowed) Error() string {
|
|
return fmt.Sprintf("name pattern is not allowed: [pattern: %s]", err.Pattern)
|
|
}
|
|
|
|
// ____ ___
|
|
// | | \______ ___________
|
|
// | | / ___// __ \_ __ \
|
|
// | | /\___ \\ ___/| | \/
|
|
// |______//____ >\___ >__|
|
|
// \/ \/
|
|
|
|
type ErrUserAlreadyExist struct {
|
|
Name string
|
|
}
|
|
|
|
func IsErrUserAlreadyExist(err error) bool {
|
|
_, ok := err.(ErrUserAlreadyExist)
|
|
return ok
|
|
}
|
|
|
|
func (err ErrUserAlreadyExist) Error() string {
|
|
return fmt.Sprintf("user already exists: [name: %s]", err.Name)
|
|
}
|
|
|
|
type ErrUserNotExist struct {
|
|
UID int64
|
|
Name string
|
|
}
|
|
|
|
func IsErrUserNotExist(err error) bool {
|
|
_, ok := err.(ErrUserNotExist)
|
|
return ok
|
|
}
|
|
|
|
func (err ErrUserNotExist) Error() string {
|
|
return fmt.Sprintf("user does not exist: [uid: %d, name: %s]", err.UID, err.Name)
|
|
}
|
|
|
|
type ErrEmailAlreadyUsed struct {
|
|
Email string
|
|
}
|
|
|
|
func IsErrEmailAlreadyUsed(err error) bool {
|
|
_, ok := err.(ErrEmailAlreadyUsed)
|
|
return ok
|
|
}
|
|
|
|
func (err ErrEmailAlreadyUsed) Error() string {
|
|
return fmt.Sprintf("e-mail has been used: [email: %s]", err.Email)
|
|
}
|
|
|
|
type ErrUserOwnRepos struct {
|
|
UID int64
|
|
}
|
|
|
|
func IsErrUserOwnRepos(err error) bool {
|
|
_, ok := err.(ErrUserOwnRepos)
|
|
return ok
|
|
}
|
|
|
|
func (err ErrUserOwnRepos) Error() string {
|
|
return fmt.Sprintf("user still has ownership of repositories: [uid: %d]", err.UID)
|
|
}
|
|
|
|
type ErrUserHasOrgs struct {
|
|
UID int64
|
|
}
|
|
|
|
func IsErrUserHasOrgs(err error) bool {
|
|
_, ok := err.(ErrUserHasOrgs)
|
|
return ok
|
|
}
|
|
|
|
func (err ErrUserHasOrgs) Error() string {
|
|
return fmt.Sprintf("user still has membership of organizations: [uid: %d]", err.UID)
|
|
}
|
|
|
|
// __________ ___. .__ .__ ____ __.
|
|
// \______ \__ _\_ |__ | | |__| ____ | |/ _|____ ___.__.
|
|
// | ___/ | \ __ \| | | |/ ___\ | <_/ __ < | |
|
|
// | | | | / \_\ \ |_| \ \___ | | \ ___/\___ |
|
|
// |____| |____/|___ /____/__|\___ > |____|__ \___ > ____|
|
|
// \/ \/ \/ \/\/
|
|
|
|
type ErrKeyNotExist struct {
|
|
ID int64
|
|
}
|
|
|
|
func IsErrKeyNotExist(err error) bool {
|
|
_, ok := err.(ErrKeyNotExist)
|
|
return ok
|
|
}
|
|
|
|
func (err ErrKeyNotExist) Error() string {
|
|
return fmt.Sprintf("public key does not exist: [id: %d]", err.ID)
|
|
}
|
|
|
|
type ErrKeyAlreadyExist struct {
|
|
OwnerID int64
|
|
Content string
|
|
}
|
|
|
|
func IsErrKeyAlreadyExist(err error) bool {
|
|
_, ok := err.(ErrKeyAlreadyExist)
|
|
return ok
|
|
}
|
|
|
|
func (err ErrKeyAlreadyExist) Error() string {
|
|
return fmt.Sprintf("public key already exists: [owner_id: %d, content: %s]", err.OwnerID, err.Content)
|
|
}
|
|
|
|
type ErrKeyNameAlreadyUsed struct {
|
|
OwnerID int64
|
|
Name string
|
|
}
|
|
|
|
func IsErrKeyNameAlreadyUsed(err error) bool {
|
|
_, ok := err.(ErrKeyNameAlreadyUsed)
|
|
return ok
|
|
}
|
|
|
|
func (err ErrKeyNameAlreadyUsed) Error() string {
|
|
return fmt.Sprintf("public key already exists: [owner_id: %d, name: %s]", err.OwnerID, err.Name)
|
|
}
|
|
|
|
type ErrDeployKeyAlreadyExist struct {
|
|
KeyID int64
|
|
RepoID int64
|
|
}
|
|
|
|
func IsErrDeployKeyAlreadyExist(err error) bool {
|
|
_, ok := err.(ErrDeployKeyAlreadyExist)
|
|
return ok
|
|
}
|
|
|
|
func (err ErrDeployKeyAlreadyExist) Error() string {
|
|
return fmt.Sprintf("public key already exists: [key_id: %d, repo_id: %d]", err.KeyID, err.RepoID)
|
|
}
|
|
|
|
type ErrDeployKeyNameAlreadyUsed struct {
|
|
RepoID int64
|
|
Name string
|
|
}
|
|
|
|
func IsErrDeployKeyNameAlreadyUsed(err error) bool {
|
|
_, ok := err.(ErrDeployKeyNameAlreadyUsed)
|
|
return ok
|
|
}
|
|
|
|
func (err ErrDeployKeyNameAlreadyUsed) Error() string {
|
|
return fmt.Sprintf("public key already exists: [repo_id: %d, name: %s]", err.RepoID, err.Name)
|
|
}
|
|
|
|
// ________ .__ __ .__
|
|
// \_____ \_______ _________ ____ |__|____________ _/ |_|__| ____ ____
|
|
// / | \_ __ \/ ___\__ \ / \| \___ /\__ \\ __\ |/ _ \ / \
|
|
// / | \ | \/ /_/ > __ \| | \ |/ / / __ \| | | ( <_> ) | \
|
|
// \_______ /__| \___ (____ /___| /__/_____ \(____ /__| |__|\____/|___| /
|
|
// \/ /_____/ \/ \/ \/ \/ \/
|
|
|
|
type ErrLastOrgOwner struct {
|
|
UID int64
|
|
}
|
|
|
|
func IsErrLastOrgOwner(err error) bool {
|
|
_, ok := err.(ErrLastOrgOwner)
|
|
return ok
|
|
}
|
|
|
|
func (err ErrLastOrgOwner) Error() string {
|
|
return fmt.Sprintf("user is the last member of owner team: [uid: %d]", err.UID)
|
|
}
|
|
|
|
// __________ .__ __
|
|
// \______ \ ____ ______ ____ _____|__|/ |_ ___________ ___.__.
|
|
// | _// __ \\____ \ / _ \/ ___/ \ __\/ _ \_ __ < | |
|
|
// | | \ ___/| |_> > <_> )___ \| || | ( <_> ) | \/\___ |
|
|
// |____|_ /\___ > __/ \____/____ >__||__| \____/|__| / ____|
|
|
// \/ \/|__| \/ \/
|
|
|
|
type ErrRepoNotExist struct {
|
|
ID int64
|
|
UID int64
|
|
Name string
|
|
}
|
|
|
|
func IsErrRepoNotExist(err error) bool {
|
|
_, ok := err.(ErrRepoNotExist)
|
|
return ok
|
|
}
|
|
|
|
func (err ErrRepoNotExist) Error() string {
|
|
return fmt.Sprintf("repository does not exist [id: %d, uid: %d, name: %s]", err.ID, err.UID, err.Name)
|
|
}
|
|
|
|
// _____ .__.__ __
|
|
// / \ |__| | ____ _______/ |_ ____ ____ ____
|
|
// / \ / \| | | _/ __ \ / ___/\ __\/ _ \ / \_/ __ \
|
|
// / Y \ | |_\ ___/ \___ \ | | ( <_> ) | \ ___/
|
|
// \____|__ /__|____/\___ >____ > |__| \____/|___| /\___ >
|
|
// \/ \/ \/ \/ \/
|
|
|
|
type ErrMilestoneNotExist struct {
|
|
ID int64
|
|
Index int64
|
|
}
|
|
|
|
func IsErrMilestoneNotExist(err error) bool {
|
|
_, ok := err.(ErrMilestoneNotExist)
|
|
return ok
|
|
}
|
|
|
|
func (err ErrMilestoneNotExist) Error() string {
|
|
return fmt.Sprintf("milestone does not exist [id: %d, index: %d]", err.ID, err.Index)
|
|
}
|