diff options
author | a1012112796 <1012112796@qq.com> | 2021-04-10 14:12:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-10 07:12:38 +0100 |
commit | e375cbfd464e12a704c3c1325315a0381ab877a7 (patch) | |
tree | 93d0769ac68625a5a365a821b1a4bf9aa3470bac /routers | |
parent | 9a0858cecf3518c9c5808bc2aeaa99278fd86cd0 (diff) | |
download | gitea-e375cbfd464e12a704c3c1325315a0381ab877a7.tar.gz gitea-e375cbfd464e12a704c3c1325315a0381ab877a7.zip |
rsponse 404 when delete not exist email (#15383)
fix #15357
Signed-off-by: a1012112796 <1012112796@qq.com>
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/user/email.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/routers/api/v1/user/email.go b/routers/api/v1/user/email.go index bc8b2fa87b..9dd35f91b6 100644 --- a/routers/api/v1/user/email.go +++ b/routers/api/v1/user/email.go @@ -111,6 +111,8 @@ func DeleteEmail(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" + // "404": + // "$ref": "#/responses/notFound" form := web.GetForm(ctx).(*api.DeleteEmailOption) if len(form.Emails) == 0 { ctx.Status(http.StatusNoContent) @@ -126,6 +128,10 @@ func DeleteEmail(ctx *context.APIContext) { } if err := models.DeleteEmailAddresses(emails); err != nil { + if models.IsErrEmailAddressNotExist(err) { + ctx.Error(http.StatusNotFound, "DeleteEmailAddresses", err) + return + } ctx.Error(http.StatusInternalServerError, "DeleteEmailAddresses", err) return } |