Skip to content

Commit

Permalink
hugolib: Recover and log panics in content init
Browse files Browse the repository at this point in the history
See #6210
  • Loading branch information
bep committed Aug 15, 2019
1 parent 028b992 commit 7f3aab5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions hugolib/page__per_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"fmt"
"html/template"
"runtime/debug"
"strings"
"sync"
"unicode/utf8"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 7f3aab5

Please sign in to comment.