Report errors when opening config files

The error handling when opening config files was ignoring all errors
except ENOEXIST.  Report other errors, instead of passing nil to
json.NewDecoder and getting:
config file: out/soong/soong.config did not parse correctly: invalid argument

Bug: 73951413
Test: touch out/soong/soong.config && chmod a-r out/soong/soong.config && m
Test: rm out/soong/soong.config && m
Change-Id: I4a609b7f060b760b76ee829b83c0eb405340f58f
This commit is contained in:
Colin Cross 2018-02-27 11:26:02 -08:00
parent d2092dbc0d
commit 15cd21a492
1 changed files with 3 additions and 1 deletions

View File

@ -132,12 +132,14 @@ func loadFromConfigFile(configurable jsonConfigurable, filename string) error {
if err != nil {
return err
}
} else if err != nil {
return fmt.Errorf("config file: could not open %s: %s", filename, err.Error())
} else {
// Make a decoder for it
jsonDecoder := json.NewDecoder(configFileReader)
err = jsonDecoder.Decode(configurable)
if err != nil {
return fmt.Errorf("config file: %s did not parse correctly: "+err.Error(), filename)
return fmt.Errorf("config file: %s did not parse correctly: %s", filename, err.Error())
}
}