mirror of
https://github.com/samsonjs/retrogit.git
synced 2026-03-25 09:25:49 +00:00
Make style JSON parse errors not be fatal.
Avoids having to restart the server when in development.
This commit is contained in:
parent
ebb7754487
commit
400c057deb
1 changed files with 5 additions and 4 deletions
|
|
@ -136,10 +136,11 @@ func loadStyles() (result map[string]template.CSS) {
|
|||
}
|
||||
var stylesJson interface{}
|
||||
err = json.Unmarshal(stylesBytes, &stylesJson)
|
||||
if err != nil {
|
||||
log.Panicf("Could not parse styles JSON %s: %s", stylesBytes, err.Error())
|
||||
}
|
||||
result = make(map[string]template.CSS)
|
||||
if err != nil {
|
||||
log.Printf("Could not parse styles JSON %s: %s", stylesBytes, err.Error())
|
||||
return
|
||||
}
|
||||
var parse func(string, map[string]interface{}, *string)
|
||||
parse = func(path string, stylesJson map[string]interface{}, currentStyle *string) {
|
||||
if path != "" {
|
||||
|
|
@ -154,7 +155,7 @@ func loadStyles() (result map[string]template.CSS) {
|
|||
parse(path+k, v.(map[string]interface{}), &nestedStyle)
|
||||
result[path+k] = template.CSS(nestedStyle)
|
||||
default:
|
||||
log.Panicf("Unexpected type for %s in styles JSON", k)
|
||||
log.Printf("Unexpected type for %s in styles JSON, ignoring", k)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue