mirror of
https://github.com/samsonjs/retrogit.git
synced 2026-04-27 15:07:43 +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{}
|
var stylesJson interface{}
|
||||||
err = json.Unmarshal(stylesBytes, &stylesJson)
|
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)
|
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)
|
var parse func(string, map[string]interface{}, *string)
|
||||||
parse = func(path string, stylesJson map[string]interface{}, currentStyle *string) {
|
parse = func(path string, stylesJson map[string]interface{}, currentStyle *string) {
|
||||||
if path != "" {
|
if path != "" {
|
||||||
|
|
@ -154,7 +155,7 @@ func loadStyles() (result map[string]template.CSS) {
|
||||||
parse(path+k, v.(map[string]interface{}), &nestedStyle)
|
parse(path+k, v.(map[string]interface{}), &nestedStyle)
|
||||||
result[path+k] = template.CSS(nestedStyle)
|
result[path+k] = template.CSS(nestedStyle)
|
||||||
default:
|
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