Browse Source

Log parse and render errors

Matt Baer 3 months ago
parent
commit
bcd4094f09
1 changed files with 9 additions and 1 deletions
  1. 9
    1
      render.go

+ 9
- 1
render.go View File

@@ -6,6 +6,7 @@ import (
6 6
 	"html/template"
7 7
 	"io"
8 8
 	"io/ioutil"
9
+	"log"
9 10
 )
10 11
 
11 12
 func Render(m *Mixtape, w io.Writer) error {
@@ -15,15 +16,22 @@ func Render(m *Mixtape, w io.Writer) error {
15 16
 	}
16 17
 	mixtapeRawTmpl, err := ioutil.ReadFile("mixtape.tmpl")
17 18
 	if err != nil {
19
+		log.Print("Unable to load local mixtape.tmpl; falling back to default")
18 20
 		mixtapeRawTmpl, err = ReadAsset("mixtape.tmpl", false)
19 21
 		if err != nil {
20 22
 			return err
21 23
 		}
24
+	} else {
25
+		log.Print("Generating from local mixtape.tmpl")
22 26
 	}
23 27
 	t, err := template.New("mixtape").Parse(string(mixtapeRawTmpl) + string(partsRawTmpl))
24 28
 	if err != nil {
29
+		log.Printf("[ERROR] Unable to parse: %v", err)
25 30
 		return err
26 31
 	}
27
-	t.ExecuteTemplate(w, "mixtape", m)
32
+	err = t.ExecuteTemplate(w, "mixtape", m)
33
+	if err != nil {
34
+		log.Printf("[ERROR] Unable to render: %v", err)
35
+	}
28 36
 	return nil
29 37
 }