hugolib: Make template panics into nice error messages
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Fri, 14 Jul 2017 08:08:04 +0000 (10:08 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Fri, 14 Jul 2017 08:08:04 +0000 (10:08 +0200)
hugolib/site.go

index 8aa1e087f5c98041319d7e6de48799200e591594..6bbf9350c3d5752a51e489a5e1f651c9adb8909d 100644 (file)
@@ -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)