Use ServerError provided by Context (#14333)

... instead of InternalServerError by macaron
release/v1.15
Lunny Xiao 2021-01-15 04:27:22 +08:00 committed by GitHub
parent f76c30094f
commit 60a3297a33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 9 deletions

View File

@ -188,7 +188,7 @@ func prepareUserInfo(ctx *context.Context) *models.User {
_, err = models.GetTwoFactorByUID(u.ID) _, err = models.GetTwoFactorByUID(u.ID)
if err != nil { if err != nil {
if !models.IsErrTwoFactorNotEnrolled(err) { if !models.IsErrTwoFactorNotEnrolled(err) {
ctx.InternalServerError(err) ctx.ServerError("IsErrTwoFactorNotEnrolled", err)
return nil return nil
} }
ctx.Data["TwoFactorEnabled"] = false ctx.Data["TwoFactorEnabled"] = false
@ -268,7 +268,7 @@ func EditUserPost(ctx *context.Context, form auth.AdminEditUserForm) {
return return
} }
if err = u.SetPassword(form.Password); err != nil { if err = u.SetPassword(form.Password); err != nil {
ctx.InternalServerError(err) ctx.ServerError("SetPassword", err)
return return
} }
} }
@ -285,12 +285,12 @@ func EditUserPost(ctx *context.Context, form auth.AdminEditUserForm) {
if form.Reset2FA { if form.Reset2FA {
tf, err := models.GetTwoFactorByUID(u.ID) tf, err := models.GetTwoFactorByUID(u.ID)
if err != nil && !models.IsErrTwoFactorNotEnrolled(err) { if err != nil && !models.IsErrTwoFactorNotEnrolled(err) {
ctx.InternalServerError(err) ctx.ServerError("GetTwoFactorByUID", err)
return return
} }
if err = models.DeleteTwoFactorByID(tf.ID, u.ID); err != nil { if err = models.DeleteTwoFactorByID(tf.ID, u.ID); err != nil {
ctx.InternalServerError(err) ctx.ServerError("DeleteTwoFactorByID", err)
return return
} }
} }

View File

@ -1117,7 +1117,7 @@ func ViewIssue(ctx *context.Context) {
iw.IssueID = issue.ID iw.IssueID = issue.ID
iw.IsWatching, err = models.CheckIssueWatch(ctx.User, issue) iw.IsWatching, err = models.CheckIssueWatch(ctx.User, issue)
if err != nil { if err != nil {
ctx.InternalServerError(err) ctx.ServerError("CheckIssueWatch", err)
return return
} }
} }

View File

@ -355,7 +355,7 @@ func DeleteProjectBoard(ctx *context.Context) {
pb, err := models.GetProjectBoard(ctx.ParamsInt64(":boardID")) pb, err := models.GetProjectBoard(ctx.ParamsInt64(":boardID"))
if err != nil { if err != nil {
ctx.InternalServerError(err) ctx.ServerError("GetProjectBoard", err)
return return
} }
if pb.ProjectID != ctx.ParamsInt64(":id") { 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")) board, err := models.GetProjectBoard(ctx.ParamsInt64(":boardID"))
if err != nil { if err != nil {
ctx.InternalServerError(err) ctx.ServerError("GetProjectBoard", err)
return return
} }
if board.ProjectID != ctx.ParamsInt64(":id") { if board.ProjectID != ctx.ParamsInt64(":id") {

View File

@ -713,11 +713,11 @@ func UpdatePullRequest(ctx *context.Context) {
} }
if err := issue.PullRequest.LoadBaseRepo(); err != nil { if err := issue.PullRequest.LoadBaseRepo(); err != nil {
ctx.InternalServerError(err) ctx.ServerError("LoadBaseRepo", err)
return return
} }
if err := issue.PullRequest.LoadHeadRepo(); err != nil { if err := issue.PullRequest.LoadHeadRepo(); err != nil {
ctx.InternalServerError(err) ctx.ServerError("LoadHeadRepo", err)
return return
} }