diff options
author | Unknwon <u@gogs.io> | 2015-08-06 22:48:11 +0800 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-08-06 22:48:11 +0800 |
commit | 39a3b768bc8b0288cb4aa91d27485f46cfbfeb29 (patch) | |
tree | bef625e010018151863344d9da3ff22d2dfbc8f9 /models/error.go | |
parent | 9f12ab0e8847682a686fdb843922a761bbb5c225 (diff) | |
download | gitea-39a3b768bc8b0288cb4aa91d27485f46cfbfeb29.tar.gz gitea-39a3b768bc8b0288cb4aa91d27485f46cfbfeb29.zip |
#334: Add Deployment Key Support
Diffstat (limited to 'models/error.go')
-rw-r--r-- | models/error.go | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/models/error.go b/models/error.go index 38a3c0534e..7851e19407 100644 --- a/models/error.go +++ b/models/error.go @@ -107,6 +107,82 @@ 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) +} + // ________ .__ __ .__ // \_____ \_______ _________ ____ |__|____________ _/ |_|__| ____ ____ // / | \_ __ \/ ___\__ \ / \| \___ /\__ \\ __\ |/ _ \ / \ |