1
0
mirror of https://github.com/thebaer/cdr.git synced 2024-11-15 01:31:01 +00:00

Log parse and render errors

This commit is contained in:
Matt Baer 2020-02-29 11:17:48 -05:00
parent ac510fa586
commit bcd4094f09

View File

@ -6,6 +6,7 @@ import (
"html/template" "html/template"
"io" "io"
"io/ioutil" "io/ioutil"
"log"
) )
func Render(m *Mixtape, w io.Writer) error { func Render(m *Mixtape, w io.Writer) error {
@ -15,15 +16,22 @@ func Render(m *Mixtape, w io.Writer) error {
} }
mixtapeRawTmpl, err := ioutil.ReadFile("mixtape.tmpl") mixtapeRawTmpl, err := ioutil.ReadFile("mixtape.tmpl")
if err != nil { if err != nil {
log.Print("Unable to load local mixtape.tmpl; falling back to default")
mixtapeRawTmpl, err = ReadAsset("mixtape.tmpl", false) mixtapeRawTmpl, err = ReadAsset("mixtape.tmpl", false)
if err != nil { if err != nil {
return err return err
} }
} else {
log.Print("Generating from local mixtape.tmpl")
} }
t, err := template.New("mixtape").Parse(string(mixtapeRawTmpl) + string(partsRawTmpl)) t, err := template.New("mixtape").Parse(string(mixtapeRawTmpl) + string(partsRawTmpl))
if err != nil { if err != nil {
log.Printf("[ERROR] Unable to parse: %v", err)
return err return err
} }
t.ExecuteTemplate(w, "mixtape", m) err = t.ExecuteTemplate(w, "mixtape", m)
if err != nil {
log.Printf("[ERROR] Unable to render: %v", err)
}
return nil return nil
} }