mirror of
https://github.com/spf13/viper
synced 2024-12-22 19:47:01 +00:00
Add error handling
Added error handling around ineffectual err assignments. Please review thoroughly.
This commit is contained in:
parent
d65fa7608b
commit
1b33e8258e
2 changed files with 4 additions and 0 deletions
3
viper.go
3
viper.go
|
@ -1469,6 +1469,9 @@ func (v *Viper) marshalWriter(f afero.File, configType string) error {
|
|||
|
||||
case "hcl":
|
||||
b, err := json.Marshal(c)
|
||||
if err != nil {
|
||||
return ConfigMarshalError{err}
|
||||
}
|
||||
ast, err := hcl.Parse(string(b))
|
||||
if err != nil {
|
||||
return ConfigMarshalError{err}
|
||||
|
|
|
@ -952,6 +952,7 @@ func TestDirsSearch(t *testing.T) {
|
|||
v.SetDefault(`key`, `default`)
|
||||
|
||||
entries, err := ioutil.ReadDir(root)
|
||||
assert.Nil(t, err)
|
||||
for _, e := range entries {
|
||||
if e.IsDir() {
|
||||
v.AddConfigPath(e.Name())
|
||||
|
|
Loading…
Reference in a new issue