Skip to content

Commit

Permalink
Add JSON file parse error checking
Browse files Browse the repository at this point in the history
  • Loading branch information
Clorith committed Mar 1, 2022
1 parent 1065eba commit b7925de
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
}
}

0 comments on commit b7925de

Please sign in to comment.