Refactor error system (#33610)
Some checks are pending
release-nightly / nightly-binary (push) Waiting to run
release-nightly / nightly-docker-rootful (push) Waiting to run
release-nightly / nightly-docker-rootless (push) Waiting to run

This commit is contained in:
wxiaoguang
2025-02-17 14:13:17 +08:00
committed by GitHub
parent 69de5a65c2
commit f35850f48e
184 changed files with 2100 additions and 2106 deletions

View File

@ -74,7 +74,7 @@ func ListMilestones(ctx *context.APIContext) {
Name: ctx.FormString("name"),
})
if err != nil {
ctx.Error(http.StatusInternalServerError, "db.FindAndCount[issues_model.Milestone]", err)
ctx.APIError(http.StatusInternalServerError, err)
return
}
@ -173,7 +173,7 @@ func CreateMilestone(ctx *context.APIContext) {
}
if err := issues_model.NewMilestone(ctx, milestone); err != nil {
ctx.Error(http.StatusInternalServerError, "NewMilestone", err)
ctx.APIError(http.StatusInternalServerError, err)
return
}
ctx.JSON(http.StatusCreated, convert.ToAPIMilestone(milestone))
@ -233,7 +233,7 @@ func EditMilestone(ctx *context.APIContext) {
}
if err := issues_model.UpdateMilestone(ctx, milestone, oldIsClosed); err != nil {
ctx.Error(http.StatusInternalServerError, "UpdateMilestone", err)
ctx.APIError(http.StatusInternalServerError, err)
return
}
ctx.JSON(http.StatusOK, convert.ToAPIMilestone(milestone))
@ -272,7 +272,7 @@ func DeleteMilestone(ctx *context.APIContext) {
}
if err := issues_model.DeleteMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, m.ID); err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteMilestoneByRepoID", err)
ctx.APIError(http.StatusInternalServerError, err)
return
}
ctx.Status(http.StatusNoContent)
@ -288,7 +288,7 @@ func getMilestoneByIDOrName(ctx *context.APIContext) *issues_model.Milestone {
if err == nil {
return milestone
} else if !issues_model.IsErrMilestoneNotExist(err) {
ctx.Error(http.StatusInternalServerError, "GetMilestoneByRepoID", err)
ctx.APIError(http.StatusInternalServerError, err)
return nil
}
}
@ -296,10 +296,10 @@ func getMilestoneByIDOrName(ctx *context.APIContext) *issues_model.Milestone {
milestone, err := issues_model.GetMilestoneByRepoIDANDName(ctx, ctx.Repo.Repository.ID, mile)
if err != nil {
if issues_model.IsErrMilestoneNotExist(err) {
ctx.NotFound()
ctx.APIErrorNotFound()
return nil
}
ctx.Error(http.StatusInternalServerError, "GetMilestoneByRepoID", err)
ctx.APIError(http.StatusInternalServerError, err)
return nil
}