Skip to content

Commit 3106f23

Browse files
author
Lapp
committed
handler: added error handling when calling the Execute method for the home page
1 parent d61ee8a commit 3106f23

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

handler.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ func (h *handler) initRoutes() {
2727
}
2828

2929
func (h *handler) index(w http.ResponseWriter, r *http.Request) {
30-
indexTemplate.Execute(w, r.Host)
30+
if err := indexTemplate.Execute(w, r.Host); err != nil {
31+
http.Error(w, "failed to load a home page", http.StatusInternalServerError)
32+
return
33+
}
3134
}
3235

3336
func (h *handler) chat(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)