mirror of
https://github.com/FairwindsOps/polaris.git
synced 2026-05-15 05:37:21 +00:00
Merge pull request #49 from reactiveops/bb/handle-template-errors
Handle errors in HTML template execution
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package dashboard
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"html/template"
|
||||
"net/http"
|
||||
@@ -47,10 +48,13 @@ func MainHandler(w http.ResponseWriter, r *http.Request, c conf.Configuration, k
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
err = template.Must(tmpl.Clone()).Execute(w, templateData)
|
||||
|
||||
buf := &bytes.Buffer{}
|
||||
err = template.Must(tmpl.Clone()).Execute(buf, templateData)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
} else {
|
||||
buf.WriteTo(w)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user