Skip to content

Commit

Permalink
log error when we fail to re-parse HTML template
Browse files Browse the repository at this point in the history
Signed-off-by: Philemon Ukane <[email protected]>
  • Loading branch information
ukane-philemon authored and chappjc committed Apr 7, 2023
1 parent 2e0968c commit 7b94d01
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions client/webserver/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,16 @@ func (t *templates) exec(name string, data interface{}) (string, error) {

if t.reloadOnExec {
// Retranslate and re-parse the template.
t.addTemplate(name, tmpl.preloads...)
log.Debugf("reloaded HTML template %q", name)

// Grab the new pageTemplate
tmpl = t.templates[name]
if err := t.addTemplate(name, tmpl.preloads...).buildErr(); err != nil {
// No need to return the error because we still want to display the
// page.
log.Errorf("Failed to reload HTML template %q: %v", name, err)
} else {
log.Debugf("reloaded HTML template %q", name)

// Grab the new pageTemplate
tmpl = t.templates[name]
}
}

var page strings.Builder
Expand Down

0 comments on commit 7b94d01

Please sign in to comment.