Verbessere Logging und Fehlerbehandlung

This commit is contained in:
Gonne 2022-09-21 22:24:08 +02:00
parent c737818ce4
commit 6e97d867de
14 changed files with 223 additions and 88 deletions

View file

@ -51,12 +51,14 @@ type Config struct {
func ReadConfigFile(filename string, conf *Config) error {
configData, err := ioutil.ReadFile(filename)
if err != nil {
log.Printf("Error reading config file: %s", err.Error())
err = fmt.Errorf("Error reading config file: %w", err)
log.Println(err.Error())
return err
}
err = json.Unmarshal(configData, conf)
if err != nil {
log.Printf("Error parsing config file as json: %s", err.Error())
err = fmt.Errorf("Error parsing config file as json: %w", err)
log.Println(err.Error())
return err
}
return validateConfig(conf)