File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,11 @@ func (pe ConfigParseError) Error() string {
31
31
return fmt .Sprintf ("While parsing config: %s" , pe .err .Error ())
32
32
}
33
33
34
+ // Unwrap returns the wrapped error.
35
+ func (pe ConfigParseError ) Unwrap () error {
36
+ return pe .err
37
+ }
38
+
34
39
// toCaseInsensitiveValue checks if the value is a map;
35
40
// if so, create a copy and lower-case the keys recursively.
36
41
func toCaseInsensitiveValue (value interface {}) interface {} {
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ package viper
8
8
import (
9
9
"bytes"
10
10
"encoding/json"
11
+ "errors"
11
12
"io"
12
13
"io/ioutil"
13
14
"os"
@@ -1573,6 +1574,18 @@ func TestWrongDirsSearchNotFoundForMerge(t *testing.T) {
1573
1574
assert .Equal (t , `default` , v .GetString (`key` ))
1574
1575
}
1575
1576
1577
+ var yamlInvalid = []byte (`hash: map
1578
+ - foo
1579
+ - bar
1580
+ ` )
1581
+
1582
+ func TestUnwrapParseErrors (t * testing.T ) {
1583
+ SetConfigType ("yaml" )
1584
+ if ! errors .As (ReadConfig (bytes .NewBuffer (yamlInvalid )), & ConfigParseError {}) {
1585
+ t .Fatalf ("not a ConfigParseError" )
1586
+ }
1587
+ }
1588
+
1576
1589
func TestSub (t * testing.T ) {
1577
1590
v := New ()
1578
1591
v .SetConfigType ("yaml" )
You can’t perform that action at this time.
0 commit comments