summaryrefslogtreecommitdiffstats
path: root/models/error.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-03-26 17:11:47 -0400
committerUnknwon <u@gogs.io>2015-03-26 17:11:47 -0400
commit698b9e2acc4daafe7d2b314e2d8c96545dde9c40 (patch)
tree8d593bb0816503494de4deb16ee0fa6b95eb3c5c /models/error.go
parentd76f11c6f14b69bf981e5fc3901cc2c6445773b8 (diff)
downloadgitea-698b9e2acc4daafe7d2b314e2d8c96545dde9c40.tar.gz
gitea-698b9e2acc4daafe7d2b314e2d8c96545dde9c40.zip
#1070 Clearer error message for illegal characters
Diffstat (limited to 'models/error.go')
-rw-r--r--models/error.go52
1 files changed, 52 insertions, 0 deletions
diff --git a/models/error.go b/models/error.go
index a434b8d6da..04f850def9 100644
--- a/models/error.go
+++ b/models/error.go
@@ -8,6 +8,32 @@ 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)
+}
+
// ____ ___
// | | \______ ___________
// | | / ___// __ \_ __ \
@@ -15,6 +41,32 @@ import (
// |______//____ >\___ >__|
// \/ \/
+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 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
}