Skip to content

Commit

Permalink
Merge pull request #87 from Juev/master
Browse files Browse the repository at this point in the history
Added error handling on Inner-Template #78
  • Loading branch information
piranha authored Nov 1, 2018
2 parents f307537 + a5eb533 commit 23ae938
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions processors/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"fmt"

gostatic "github.com/piranha/gostatic/lib"
)

Expand Down Expand Up @@ -60,6 +61,7 @@ func ProcessInnerTemplate(page *gostatic.Page, args []string) error {
//todo catch
defer func() {
if err := recover(); err != nil {
fmt.Printf("%s: %s\n", page.Source, err)
//return fmt.Sprintf("%s: %s", page.Source, err)
}
}()
Expand All @@ -70,13 +72,13 @@ func ProcessInnerTemplate(page *gostatic.Page, args []string) error {
}
t, err = t.New("ad-hoc").Parse(page.Content())
if err != nil {
return errors.New(fmt.Sprintf("Page %s: %s", page.Source, err))
return fmt.Errorf("Page %s: %s", page.Source, err)
}

var buffer bytes.Buffer
err = t.ExecuteTemplate(&buffer, "ad-hoc", page)
if err != nil {
return errors.New(fmt.Sprintf("Page %s: %s", page.Source, err))
return fmt.Errorf("Page %s: %s", page.Source, err)
}

page.SetContent(buffer.String())
Expand Down

0 comments on commit 23ae938

Please sign in to comment.