shithub: hugo

Download patch

ref: e951d65771ca299aa899e91bfe00411a5ada8f19
parent: 2bcbf104006e0ec03be4fd500f2519301d460f8c
author: Bjørn Erik Pedersen <[email protected]>
date: Sat May 6 06:48:27 EDT 2017

hugolib: Handle any errors in processShortcodes

--- a/hugolib/handler_page.go
+++ b/hugolib/handler_page.go
@@ -79,7 +79,9 @@
 	// 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 @@
 	// 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.
--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -1371,10 +1371,15 @@
 	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
 
 }