Skip to content

Commit

Permalink
(81) Add path to error message for yaml
Browse files Browse the repository at this point in the history
This adds the path of the yaml file when `YamlData`
fails to read or unmarshal the file.
  • Loading branch information
hlindberg committed Sep 8, 2020
1 parent d384bbf commit a1f58fe
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions provider/yamldata.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package provider

import (
"fmt"
"io/ioutil"
"os"

Expand All @@ -23,11 +24,11 @@ func YamlData(ctx hiera.ProviderContext) dgo.Map {
if os.IsNotExist(err) {
return vf.Map()
}
panic(err)
panic(fmt.Errorf("Could not read %s: %s", path, err.Error()))
}
v, err := yaml.Unmarshal(bs)
if err != nil {
panic(err)
panic(fmt.Errorf("Could not unmarshal %s: %s", path, err.Error()))
}
if data, ok := v.(dgo.Map); ok {
return data
Expand Down

0 comments on commit a1f58fe

Please sign in to comment.