From d5619201472be88d5f5c5b99b4ba99c73ff8d63e Mon Sep 17 00:00:00 2001 From: Jeff Levin Date: Wed, 22 Mar 2023 11:40:00 -0800 Subject: [PATCH] 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 --- pkg/web/context.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/web/context.go b/pkg/web/context.go index 413ac3709d6..8375c92097b 100644 --- a/pkg/web/context.go +++ b/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())) } }