From bb9b1a868bf4d787cb7f170d85ac95e402691f23 Mon Sep 17 00:00:00 2001 From: Sergey Gladkovskiy Date: Tue, 9 Apr 2019 14:32:07 +0300 Subject: [PATCH] handling config file errors --- reader.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/reader.go b/reader.go index 9b7075c..3e3af0f 100644 --- a/reader.go +++ b/reader.go @@ -72,12 +72,15 @@ func ReadConfigs(cfgPath string) ([]byte, error) { configs := make(map[string]map[string]interface{}) for folder, files := range fileList { for _, file := range files { - configBytes, _ := ioutil.ReadFile(cfgPath + "/" + folder + "/" + file) + configBytes, err := ioutil.ReadFile(cfgPath + "/" + folder + "/" + file) + if err != nil { + log.Fatalf("[config] Error reading config file %s: %v", cfgPath+"/"+folder+"/"+file, err) + } var configFromFile map[string]map[string]interface{} if err = yaml.Unmarshal(configBytes, &configFromFile); err != nil { - log.Fatalf("[config] %s %s config read fal! Fall down.", folder, file) + log.Fatalf("[config] %s %s config read fail! Fall down.", folder, file) } if _, ok := configFromFile[folder]; !ok {