Skip to content

Commit

Permalink
Merge pull request #83 from hlindberg/add-path-to-error-message-for-y…
Browse files Browse the repository at this point in the history
…aml-data

(81) Add path to error message for yaml
  • Loading branch information
thallgren authored Sep 8, 2020
2 parents d384bbf + 3bfdba1 commit 7eec6a6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion api/invocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type Invocation interface {
MergeHierarchy(key Key, providers []DataProvider, merge MergeStrategy) dgo.Value

// MergeLocations merges the result of lookups on all locations (or without location) for the
//given provider and merge options
// given provider and merge options
MergeLocations(key Key, provider DataProvider, merge MergeStrategy) dgo.Value

// ReportText will add the message returned by the given function to the
Expand Down
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 7eec6a6

Please sign in to comment.