Check for errors when executing templates

This commit is contained in:
2024-10-04 10:21:56 +02:00
parent cf4d4f151a
commit b3f31f398d
5 changed files with 248 additions and 51 deletions

View File

@@ -132,7 +132,11 @@ func PublishLatestIssue(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFun
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
tmpl = template.Must(tmpl, err)
tmpl.ExecuteTemplate(w, "page-content", session.Values["role"])
if err = tmpl.ExecuteTemplate(w, "page-content", session.Values["role"]); err != nil {
log.Println(err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
}
}