Add error handling - viper - [fork] go viper port for 9front
(HTM) git clone git@git.drkhsh.at/viper.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 1b33e8258e07ea1da9064b06ee29a0d0831b693d
(DIR) parent d65fa7608b54d861eae8524279cdc7e52f4dd432
(HTM) Author: Christian Muehlhaeuser <muesli@gmail.com>
Date: Sat, 20 Jul 2019 00:10:42 +0200
Add error handling
Added error handling around ineffectual err assignments. Please review
thoroughly.
Diffstat:
M viper.go | 3 +++
M viper_test.go | 1 +
2 files changed, 4 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/viper.go b/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}
(DIR) diff --git a/viper_test.go b/viper_test.go
@@ -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())