mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 20:01:02 +00:00
Improve error messages in template parsing init().
This commit is contained in:
parent
526fc23299
commit
dbbbe325c3
1 changed files with 20 additions and 2 deletions
|
@ -2,6 +2,7 @@ package template
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"io"
|
||||
|
||||
|
@ -109,7 +110,16 @@ func init() {
|
|||
}
|
||||
|
||||
// parse the template and then add to the global map
|
||||
registry[file] = template.Must(template.Must(template.New("_").Parse(baseTemplate)).Parse(page))
|
||||
baseParsed, err := template.New("_").Parse(baseTemplate)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("Error parsing base.html template: %s", err))
|
||||
}
|
||||
pageParsed, err := baseParsed.Parse(page)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("Error parsing page template for %s: %s", file, err))
|
||||
}
|
||||
|
||||
registry[file] = pageParsed
|
||||
}
|
||||
|
||||
// location of templates
|
||||
|
@ -136,8 +146,16 @@ func init() {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
baseParsed, err := template.New("_").Parse(base)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("Error parsing base_email.html template: %s", err))
|
||||
}
|
||||
emailParsed, err := baseParsed.Parse(email)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("Error parsing email template for %s: %s", file, err))
|
||||
}
|
||||
|
||||
// parse the template and then add to the global map
|
||||
registry[file] = template.Must(template.Must(template.New("_").Parse(base)).Parse(email))
|
||||
registry[file] = emailParsed
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue