From e951d65771ca299aa899e91bfe00411a5ada8f19 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Sat, 6 May 2017 10:48:27 +0200 Subject: [PATCH] hugolib: Handle any errors in processShortcodes --- hugolib/handler_page.go | 8 ++++++-- hugolib/page.go | 9 +++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/hugolib/handler_page.go b/hugolib/handler_page.go index 6439344b..a7dbff2e 100644 --- a/hugolib/handler_page.go +++ b/hugolib/handler_page.go @@ -79,7 +79,9 @@ func (h htmlHandler) PageConvert(p *Page) HandledResult { // Work on a copy of the raw content from now on. p.createWorkContentCopy() - p.ProcessShortcodes() + if err := p.processShortcodes(); err != nil { + return HandledResult{err: err} + } return HandledResult{err: nil} } @@ -128,7 +130,9 @@ func commonConvert(p *Page) HandledResult { // Work on a copy of the raw content from now on. p.createWorkContentCopy() - p.ProcessShortcodes() + if err := p.processShortcodes(); err != nil { + return HandledResult{err: err} + } // TODO(bep) these page handlers need to be re-evaluated, as it is hard to // process a page in isolation. See the new preRender func. diff --git a/hugolib/page.go b/hugolib/page.go index 8479288d..21603c3d 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -1371,11 +1371,16 @@ func (p *Page) SaveSource() error { return p.SaveSourceAs(p.FullFilePath()) } -func (p *Page) ProcessShortcodes() { +func (p *Page) processShortcodes() error { p.shortcodeState = newShortcodeHandler() - tmpContent, _ := p.shortcodeState.extractAndRenderShortcodes(string(p.workContent), p) + tmpContent, err := p.shortcodeState.extractAndRenderShortcodes(string(p.workContent), p) + if err != nil { + return err + } p.workContent = []byte(tmpContent) + return nil + } func (p *Page) FullFilePath() string { -- 2.30.2