Skip to content

Commit a1c0b3a

Browse files
lunnyKN4CK3R
andauthored
Display friendly error message (#29105) (#29363)
Backport #29105 `ctx.Error` only displays the text but `ctx.ServerError` renders the usual error page. Co-authored-by: KN4CK3R <[email protected]>
1 parent 6624f25 commit a1c0b3a

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

@@ -96,7 +96,7 @@ func List(ctx *context.Context) {
9696
workflow := Workflow{Entry: *entry}
9797
content, err := actions.GetContentFromEntry(entry)
9898
if err != nil {
99-
ctx.Error(http.StatusInternalServerError, err.Error())
99+
ctx.ServerError("GetContentFromEntry", err)
100100
return
101101
}
102102
wf, err := model.ReadWorkflow(bytes.NewReader(content))
@@ -173,7 +173,7 @@ func List(ctx *context.Context) {
173173

174174
runs, total, err := actions_model.FindRuns(ctx, opts)
175175
if err != nil {
176-
ctx.Error(http.StatusInternalServerError, err.Error())
176+
ctx.ServerError("FindAndCount", err)
177177
return
178178
}
179179

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

184184
if err := runs.LoadTriggerUser(ctx); err != nil {
185-
ctx.Error(http.StatusInternalServerError, err.Error())
185+
ctx.ServerError("LoadTriggerUser", err)
186186
return
187187
}
188188

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

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

0 commit comments

Comments
 (0)