From 794ea21e9449b876c5514f1ce8fe61449bbe4980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Fri, 14 Jul 2017 10:08:04 +0200 Subject: [PATCH] hugolib: Make template panics into nice error messages --- hugolib/site.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hugolib/site.go b/hugolib/site.go index 8aa1e087f..6bbf9350c 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -1967,6 +1967,9 @@ func (s *Site) renderAndWritePage(name string, dest string, p *PageOutput, layou } func (s *Site) renderForLayouts(name string, d interface{}, w io.Writer, layouts ...string) error { + defer func() { + recover() + }() templ := s.findFirstTemplate(layouts...) if templ == nil { return fmt.Errorf("[%s] Unable to locate layout for %q: %s\n", s.Language.Lang, name, layouts)