Context: add better error message when it panics loading a template (#65219)

add better error message about building frontend assets when the web server panics loading a template
pull/65236/head
Jeff Levin 2 years ago committed by GitHub
parent b033fe8d73
commit d561920147
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      pkg/web/context.go

@ -16,6 +16,7 @@ package web
import (
"encoding/json"
"fmt"
"html/template"
"net"
"net/http"
@ -103,7 +104,7 @@ func (ctx *Context) HTML(status int, name string, data interface{}) {
ctx.Resp.Header().Set(headerContentType, contentTypeHTML)
ctx.Resp.WriteHeader(status)
if err := ctx.template.ExecuteTemplate(ctx.Resp, name, data); err != nil {
panic("Context.HTML:" + err.Error())
panic(fmt.Sprintf("Context.HTML - Error rendering template: %s. You may need to build frontend assets \n %s", name, err.Error()))
}
}

Loading…
Cancel
Save