Skip to content

Commit

Permalink
Use ServerError provided by Context (#14333)
Browse files Browse the repository at this point in the history
... instead of InternalServerError by macaron
  • Loading branch information
lunny committed Jan 14, 2021
1 parent f76c300 commit 60a3297
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions routers/admin/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}
Expand All @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion routers/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
4 changes: 2 additions & 2 deletions routers/repo/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -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") {
Expand Down
4 changes: 2 additions & 2 deletions routers/repo/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 60a3297

Please sign in to comment.