mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-24 09:27:17 +00:00
[gitea] Display friendly error message (#29105)
`ctx.Error` only displays the text but `ctx.ServerError` renders the usual error page. (cherry picked from commit da2f03750f9672c5aac48209539874f2af2673f1)
This commit is contained in:
parent
0d62b52f4f
commit
045bd097c6
|
@ -61,17 +61,17 @@ func List(ctx *context.Context) {
|
||||||
|
|
||||||
var workflows []Workflow
|
var workflows []Workflow
|
||||||
if empty, err := ctx.Repo.GitRepo.IsEmpty(); err != nil {
|
if empty, err := ctx.Repo.GitRepo.IsEmpty(); err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, err.Error())
|
ctx.ServerError("IsEmpty", err)
|
||||||
return
|
return
|
||||||
} else if !empty {
|
} else if !empty {
|
||||||
commit, err := ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.Repository.DefaultBranch)
|
commit, err := ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.Repository.DefaultBranch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, err.Error())
|
ctx.ServerError("GetBranchCommit", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
entries, err := actions.ListWorkflows(commit)
|
entries, err := actions.ListWorkflows(commit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, err.Error())
|
ctx.ServerError("ListWorkflows", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ func List(ctx *context.Context) {
|
||||||
workflow := Workflow{Entry: *entry}
|
workflow := Workflow{Entry: *entry}
|
||||||
content, err := actions.GetContentFromEntry(entry)
|
content, err := actions.GetContentFromEntry(entry)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, err.Error())
|
ctx.ServerError("GetContentFromEntry", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
wf, err := model.ReadWorkflow(bytes.NewReader(content))
|
wf, err := model.ReadWorkflow(bytes.NewReader(content))
|
||||||
|
@ -172,7 +172,7 @@ func List(ctx *context.Context) {
|
||||||
|
|
||||||
runs, total, err := db.FindAndCount[actions_model.ActionRun](ctx, opts)
|
runs, total, err := db.FindAndCount[actions_model.ActionRun](ctx, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, err.Error())
|
ctx.ServerError("FindAndCount", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ func List(ctx *context.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := actions_model.RunList(runs).LoadTriggerUser(ctx); err != nil {
|
if err := actions_model.RunList(runs).LoadTriggerUser(ctx); err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, err.Error())
|
ctx.ServerError("LoadTriggerUser", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ func List(ctx *context.Context) {
|
||||||
|
|
||||||
actors, err := actions_model.GetActors(ctx, ctx.Repo.Repository.ID)
|
actors, err := actions_model.GetActors(ctx, ctx.Repo.Repository.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, err.Error())
|
ctx.ServerError("GetActors", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.Data["Actors"] = repo.MakeSelfOnTop(ctx.Doer, actors)
|
ctx.Data["Actors"] = repo.MakeSelfOnTop(ctx.Doer, actors)
|
||||||
|
|
Loading…
Reference in a new issue