aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api
diff options
context:
space:
mode:
authorChris Shyi <chrisshyi13@gmail.com>2020-10-12 21:44:56 +0800
committerGitHub <noreply@github.com>2020-10-12 14:44:56 +0100
commitc752ccee6425091cf17c98029f039f3fe66552b4 (patch)
tree1fd499117672e13c6323f433577ad98f1d4a197d /routers/api
parent0e4f663126dbd39266e56203cca48b8a5aa85ee6 (diff)
downloadgitea-c752ccee6425091cf17c98029f039f3fe66552b4.tar.gz
gitea-c752ccee6425091cf17c98029f039f3fe66552b4.zip
Improve error feedback for duplicate deploy keys (#13112)
Instead of a generic HTTP 500 error page, a flash message is rendered with the deploy key page template to inform the user that a key with the intended title already exists. Fixes #13110
Diffstat (limited to 'routers/api')
-rw-r--r--routers/api/v1/repo/key.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/routers/api/v1/repo/key.go b/routers/api/v1/repo/key.go
index 5d63a25d64..3d16ae6d40 100644
--- a/routers/api/v1/repo/key.go
+++ b/routers/api/v1/repo/key.go
@@ -177,6 +177,8 @@ func HandleAddKeyError(ctx *context.APIContext, err error) {
ctx.Error(http.StatusUnprocessableEntity, "", "Key content has been used as non-deploy key")
case models.IsErrKeyNameAlreadyUsed(err):
ctx.Error(http.StatusUnprocessableEntity, "", "Key title has been used")
+ case models.IsErrDeployKeyNameAlreadyUsed(err):
+ ctx.Error(http.StatusUnprocessableEntity, "", "A key with the same name already exists")
default:
ctx.Error(http.StatusInternalServerError, "AddKey", err)
}