shithub: hugo

Download patch

ref: 794ea21e9449b876c5514f1ce8fe61449bbe4980
parent: 91f410ea902fa32e042242f39c2e78f9cd6887ac
author: Bjørn Erik Pedersen <[email protected]>
date: Fri Jul 14 06:08:04 EDT 2017

hugolib: Make template panics into nice error messages

--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -1967,6 +1967,9 @@
 }
 
 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)