From b7925de8c70c76f923f326d334def355f861dc48 Mon Sep 17 00:00:00 2001 From: Marius Jensen Date: Tue, 1 Mar 2022 20:17:42 +0100 Subject: [PATCH] Add JSON file parse error checking --- internal/config/config.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/config/config.go b/internal/config/config.go index d3a91f9..f3a097c 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -77,5 +77,10 @@ func (c *Config) ParseConfig(filepath string) { jsonReader := strings.NewReader(string(jsonConfig)) jsonParser := json.NewDecoder(jsonReader) - jsonParser.Decode(c) + err = jsonParser.Decode(c) + + // Make sure the JSON read is valid. + if err != nil { + log.Fatalf("JSON file not valid!") + } }