From 400c057debed5d47a59b3f564f550e373e9b0c52 Mon Sep 17 00:00:00 2001 From: Mihai Parparita Date: Sun, 26 Oct 2014 22:53:46 -0700 Subject: [PATCH] Make style JSON parse errors not be fatal. Avoids having to restart the server when in development. --- app/retrogit.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/retrogit.go b/app/retrogit.go index 5eb5ff6..e6c66b8 100644 --- a/app/retrogit.go +++ b/app/retrogit.go @@ -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) } } }