]> source.dussan.org Git - gitea.git/commitdiff
Use ServerError provided by Context (#14333)
authorLunny Xiao <xiaolunwen@gmail.com>
Thu, 14 Jan 2021 20:27:22 +0000 (04:27 +0800)
committerGitHub <noreply@github.com>
Thu, 14 Jan 2021 20:27:22 +0000 (21:27 +0100)
... instead of InternalServerError by macaron

routers/admin/users.go
routers/repo/issue.go
routers/repo/projects.go
routers/repo/pull.go

index 9fe5c3ef7deec2dbbcc5c20060b0f24882e84daf..74fce9a10cb53e4f3fd8d29de7eb51ef5fd8cd13 100644 (file)
@@ -188,7 +188,7 @@ func prepareUserInfo(ctx *context.Context) *models.User {
        _, err = models.GetTwoFactorByUID(u.ID)
        if err != nil {
                if !models.IsErrTwoFactorNotEnrolled(err) {
-                       ctx.InternalServerError(err)
+                       ctx.ServerError("IsErrTwoFactorNotEnrolled", err)
                        return nil
                }
                ctx.Data["TwoFactorEnabled"] = false
@@ -268,7 +268,7 @@ func EditUserPost(ctx *context.Context, form auth.AdminEditUserForm) {
                        return
                }
                if err = u.SetPassword(form.Password); err != nil {
-                       ctx.InternalServerError(err)
+                       ctx.ServerError("SetPassword", err)
                        return
                }
        }
@@ -285,12 +285,12 @@ func EditUserPost(ctx *context.Context, form auth.AdminEditUserForm) {
        if form.Reset2FA {
                tf, err := models.GetTwoFactorByUID(u.ID)
                if err != nil && !models.IsErrTwoFactorNotEnrolled(err) {
-                       ctx.InternalServerError(err)
+                       ctx.ServerError("GetTwoFactorByUID", err)
                        return
                }
 
                if err = models.DeleteTwoFactorByID(tf.ID, u.ID); err != nil {
-                       ctx.InternalServerError(err)
+                       ctx.ServerError("DeleteTwoFactorByID", err)
                        return
                }
        }
index 1d8d9c0366cc59ebb49609413f955d4e74e5f403..478baf8d86aa86b9a2faa8a0ebec06e87ebc144b 100644 (file)
@@ -1117,7 +1117,7 @@ func ViewIssue(ctx *context.Context) {
                iw.IssueID = issue.ID
                iw.IsWatching, err = models.CheckIssueWatch(ctx.User, issue)
                if err != nil {
-                       ctx.InternalServerError(err)
+                       ctx.ServerError("CheckIssueWatch", err)
                        return
                }
        }
index 07327df9eb06dc1d53b4fbb7f265c6334cbcfc33..08746aad984af235140741cbadcf4b29e9e1033e 100644 (file)
@@ -355,7 +355,7 @@ func DeleteProjectBoard(ctx *context.Context) {
 
        pb, err := models.GetProjectBoard(ctx.ParamsInt64(":boardID"))
        if err != nil {
-               ctx.InternalServerError(err)
+               ctx.ServerError("GetProjectBoard", err)
                return
        }
        if pb.ProjectID != ctx.ParamsInt64(":id") {
@@ -445,7 +445,7 @@ func EditProjectBoardTitle(ctx *context.Context, form auth.EditProjectBoardTitle
 
        board, err := models.GetProjectBoard(ctx.ParamsInt64(":boardID"))
        if err != nil {
-               ctx.InternalServerError(err)
+               ctx.ServerError("GetProjectBoard", err)
                return
        }
        if board.ProjectID != ctx.ParamsInt64(":id") {
index 1594e9a9c4feac8c0fd9bc0c1dd2e5da2cbbed38..01c6efaa1de8179484f11d68ae9d14c5b517a7b7 100644 (file)
@@ -713,11 +713,11 @@ func UpdatePullRequest(ctx *context.Context) {
        }
 
        if err := issue.PullRequest.LoadBaseRepo(); err != nil {
-               ctx.InternalServerError(err)
+               ctx.ServerError("LoadBaseRepo", err)
                return
        }
        if err := issue.PullRequest.LoadHeadRepo(); err != nil {
-               ctx.InternalServerError(err)
+               ctx.ServerError("LoadHeadRepo", err)
                return
        }