mirror of
https://github.com/spf13/viper
synced 2024-11-04 20:27:02 +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":
|
case "hcl":
|
||||||
b, err := json.Marshal(c)
|
b, err := json.Marshal(c)
|
||||||
|
if err != nil {
|
||||||
|
return ConfigMarshalError{err}
|
||||||
|
}
|
||||||
ast, err := hcl.Parse(string(b))
|
ast, err := hcl.Parse(string(b))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ConfigMarshalError{err}
|
return ConfigMarshalError{err}
|
||||||
|
|
|
@ -952,6 +952,7 @@ func TestDirsSearch(t *testing.T) {
|
||||||
v.SetDefault(`key`, `default`)
|
v.SetDefault(`key`, `default`)
|
||||||
|
|
||||||
entries, err := ioutil.ReadDir(root)
|
entries, err := ioutil.ReadDir(root)
|
||||||
|
assert.Nil(t, err)
|
||||||
for _, e := range entries {
|
for _, e := range entries {
|
||||||
if e.IsDir() {
|
if e.IsDir() {
|
||||||
v.AddConfigPath(e.Name())
|
v.AddConfigPath(e.Name())
|
||||||
|
|
Loading…
Reference in a new issue