Code cleanup in the actions.ViewLatest route handler

Based on feedback received after the feature was merged, use
`ctx.NotFound` and `ctx.ServerError`, and drop the use of the
unnecessary `ctx.Written()`.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
This commit is contained in:
Gergely Nagy 2023-12-10 17:56:11 +01:00
parent c3f487af49
commit 74e42da563
No known key found for this signature in database

View file

@ -49,14 +49,12 @@ func View(ctx *context_module.Context) {
func ViewLatest(ctx *context_module.Context) { func ViewLatest(ctx *context_module.Context) {
run, err := actions_model.GetLatestRun(ctx, ctx.Repo.Repository.ID) run, err := actions_model.GetLatestRun(ctx, ctx.Repo.Repository.ID)
if err != nil { if err != nil {
ctx.Error(http.StatusNotFound, err.Error()) ctx.NotFound("GetLatestRun", err)
ctx.Written()
return return
} }
err = run.LoadAttributes(ctx) err = run.LoadAttributes(ctx)
if err != nil { if err != nil {
ctx.Error(http.StatusInternalServerError, err.Error()) ctx.ServerError("LoadAttributes", err)
ctx.Written()
return return
} }
ctx.Redirect(run.HTMLURL(), http.StatusTemporaryRedirect) ctx.Redirect(run.HTMLURL(), http.StatusTemporaryRedirect)