aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1/user/email.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/api/v1/user/email.go')
-rw-r--r--routers/api/v1/user/email.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/routers/api/v1/user/email.go b/routers/api/v1/user/email.go
index 07fcde625e..d848f5e58d 100644
--- a/routers/api/v1/user/email.go
+++ b/routers/api/v1/user/email.go
@@ -5,6 +5,7 @@
package user
import (
+ "fmt"
"net/http"
"code.gitea.io/gitea/models"
@@ -78,6 +79,9 @@ func AddEmail(ctx *context.APIContext, form api.CreateEmailOption) {
if err := models.AddEmailAddresses(emails); err != nil {
if models.IsErrEmailAlreadyUsed(err) {
ctx.Error(http.StatusUnprocessableEntity, "", "Email address has been used: "+err.(models.ErrEmailAlreadyUsed).Email)
+ } else if models.IsErrEmailInvalid(err) {
+ errMsg := fmt.Sprintf("Email address %s invalid", err.(models.ErrEmailInvalid).Email)
+ ctx.Error(http.StatusUnprocessableEntity, "", errMsg)
} else {
ctx.Error(http.StatusInternalServerError, "AddEmailAddresses", err)
}