summaryrefslogtreecommitdiffstats
path: root/hugolib/page__per_output.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-08-15 10:56:49 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-08-15 10:56:49 +0200
commit7f3aab5ac283ecfc7029b680d4c0a34920e728c8 (patch)
tree8fbbb8e8a29b62b15caa0ec40005cf7b9263acbe /hugolib/page__per_output.go
parent028b992611209b241b1f55def8d47f9188038dc3 (diff)
hugolib: Recover and log panics in content init
See #6210
Diffstat (limited to 'hugolib/page__per_output.go')
-rw-r--r--hugolib/page__per_output.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/hugolib/page__per_output.go b/hugolib/page__per_output.go
index aa0fcd488..70bb3b223 100644
--- a/hugolib/page__per_output.go
+++ b/hugolib/page__per_output.go
@@ -18,6 +18,7 @@ import (
"context"
"fmt"
"html/template"
+ "runtime/debug"
"strings"
"sync"
"unicode/utf8"
@@ -65,8 +66,15 @@ func newPageContentOutput(p *pageState) func(f output.Format) (*pageContentOutpu
f: f,
}
- initContent := func() error {
- var err error
+ initContent := func() (err error) {
+ defer func() {
+ // See https://github.com/gohugoio/hugo/issues/6210
+ if r := recover(); r != nil {
+ err = fmt.Errorf("%s", r)
+ p.s.Log.ERROR.Println("[BUG] Got panic:\n", string(debug.Stack()))
+ }
+ }()
+
var hasVariants bool
cp.contentPlaceholders, hasVariants, err = p.shortcodeState.renderShortcodesForPage(p, f)