Skip to content

Commit

Permalink
Display friendly error message (go-gitea#29105)
Browse files Browse the repository at this point in the history
`ctx.Error` only displays the text but `ctx.ServerError` renders the
usual error page.
  • Loading branch information
KN4CK3R authored Feb 8, 2024
1 parent ce9978b commit da2f037
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions routers/web/repo/actions/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,17 @@ func List(ctx *context.Context) {

var workflows []Workflow
if empty, err := ctx.Repo.GitRepo.IsEmpty(); err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.ServerError("IsEmpty", err)
return
} else if !empty {
commit, err := ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.Repository.DefaultBranch)
if err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.ServerError("GetBranchCommit", err)
return
}
entries, err := actions.ListWorkflows(commit)
if err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.ServerError("ListWorkflows", err)
return
}

Expand All @@ -95,7 +95,7 @@ func List(ctx *context.Context) {
workflow := Workflow{Entry: *entry}
content, err := actions.GetContentFromEntry(entry)
if err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.ServerError("GetContentFromEntry", err)
return
}
wf, err := model.ReadWorkflow(bytes.NewReader(content))
Expand Down Expand Up @@ -172,7 +172,7 @@ func List(ctx *context.Context) {

runs, total, err := db.FindAndCount[actions_model.ActionRun](ctx, opts)
if err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.ServerError("FindAndCount", err)
return
}

Expand All @@ -181,15 +181,15 @@ func List(ctx *context.Context) {
}

if err := actions_model.RunList(runs).LoadTriggerUser(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.ServerError("LoadTriggerUser", err)
return
}

ctx.Data["Runs"] = runs

actors, err := actions_model.GetActors(ctx, ctx.Repo.Repository.ID)
if err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.ServerError("GetActors", err)
return
}
ctx.Data["Actors"] = repo.MakeSelfOnTop(ctx.Doer, actors)
Expand Down

0 comments on commit da2f037

Please sign in to comment.