diff options
author | Chris Shyi <chrisshyi13@gmail.com> | 2020-10-12 21:44:56 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-12 14:44:56 +0100 |
commit | c752ccee6425091cf17c98029f039f3fe66552b4 (patch) | |
tree | 1fd499117672e13c6323f433577ad98f1d4a197d /routers/api | |
parent | 0e4f663126dbd39266e56203cca48b8a5aa85ee6 (diff) | |
download | gitea-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.go | 2 |
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) } |