Skip to content

Commit da2f037

Browse files
authored
Display friendly error message (#29105)
`ctx.Error` only displays the text but `ctx.ServerError` renders the usual error page.
1 parent ce9978b commit da2f037

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

routers/web/repo/actions/actions.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,17 @@ func List(ctx *context.Context) {
6161

6262
var workflows []Workflow
6363
if empty, err := ctx.Repo.GitRepo.IsEmpty(); err != nil {
64-
ctx.Error(http.StatusInternalServerError, err.Error())
64+
ctx.ServerError("IsEmpty", err)
6565
return
6666
} else if !empty {
6767
commit, err := ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.Repository.DefaultBranch)
6868
if err != nil {
69-
ctx.Error(http.StatusInternalServerError, err.Error())
69+
ctx.ServerError("GetBranchCommit", err)
7070
return
7171
}
7272
entries, err := actions.ListWorkflows(commit)
7373
if err != nil {
74-
ctx.Error(http.StatusInternalServerError, err.Error())
74+
ctx.ServerError("ListWorkflows", err)
7575
return
7676
}
7777

@@ -95,7 +95,7 @@ func List(ctx *context.Context) {
9595
workflow := Workflow{Entry: *entry}
9696
content, err := actions.GetContentFromEntry(entry)
9797
if err != nil {
98-
ctx.Error(http.StatusInternalServerError, err.Error())
98+
ctx.ServerError("GetContentFromEntry", err)
9999
return
100100
}
101101
wf, err := model.ReadWorkflow(bytes.NewReader(content))
@@ -172,7 +172,7 @@ func List(ctx *context.Context) {
172172

173173
runs, total, err := db.FindAndCount[actions_model.ActionRun](ctx, opts)
174174
if err != nil {
175-
ctx.Error(http.StatusInternalServerError, err.Error())
175+
ctx.ServerError("FindAndCount", err)
176176
return
177177
}
178178

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

183183
if err := actions_model.RunList(runs).LoadTriggerUser(ctx); err != nil {
184-
ctx.Error(http.StatusInternalServerError, err.Error())
184+
ctx.ServerError("LoadTriggerUser", err)
185185
return
186186
}
187187

188188
ctx.Data["Runs"] = runs
189189

190190
actors, err := actions_model.GetActors(ctx, ctx.Repo.Repository.ID)
191191
if err != nil {
192-
ctx.Error(http.StatusInternalServerError, err.Error())
192+
ctx.ServerError("GetActors", err)
193193
return
194194
}
195195
ctx.Data["Actors"] = repo.MakeSelfOnTop(ctx.Doer, actors)

0 commit comments

Comments
 (0)