Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
handling config file errors
Browse files Browse the repository at this point in the history
  • Loading branch information
smgladkovskiy committed Apr 9, 2019
1 parent 75e1075 commit bb9b1a8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit bb9b1a8

Please sign in to comment.