cleanup errors
alex wennerberg alex@alexwennerberg.com
Sat, 24 Oct 2020 11:35:43 -0700
2 files changed,
8 insertions(+),
3 deletions(-)
M
http.go
→
http.go
@@ -20,7 +20,10 @@
const InternalServerErrorMsg = "500: Internal Server Error" func renderError(w http.ResponseWriter, errorMsg string, statusCode int) { - data := struct{ ErrorMsg string }{errorMsg} + data := struct { + PageTitle string + ErrorMsg string + }{"Error!", errorMsg} err := t.ExecuteTemplate(w, "error.html", data) if err != nil { // shouldn't happen probably http.Error(w, errorMsg, statusCode)@@ -58,7 +61,6 @@ log.Println(err)
renderError(w, InternalServerErrorMsg, 500) return } - } func editFileHandler(w http.ResponseWriter, r *http.Request) {
M
templates/error.html
→
templates/error.html
@@ -1,1 +1,4 @@
-{{ .ErrorMsg }} +{{template "header" .}} +<h1>Error</h1> +<div class="error">{{ .ErrorMsg }}</div> +{{template "footer" .}}