mirror of
https://github.com/spf13/viper
synced 2025-05-07 20:57:18 +00:00
Allow ConfigParseError to unwrap
This commit is contained in:
parent
419fd86e49
commit
d4014cfce7
2 changed files with 7 additions and 2 deletions
7
util.go
7
util.go
|
@ -27,10 +27,15 @@ type ConfigParseError struct {
|
|||
}
|
||||
|
||||
// Error returns the formatted configuration error.
|
||||
func (pe ConfigParseError) Error() string {
|
||||
func (pe *ConfigParseError) Error() string {
|
||||
return fmt.Sprintf("While parsing config: %s", pe.err.Error())
|
||||
}
|
||||
|
||||
// Unwrap returns the wrapped error.
|
||||
func (pe *ConfigParseError) Unwrap() error {
|
||||
return pe.err
|
||||
}
|
||||
|
||||
// toCaseInsensitiveValue checks if the value is a map;
|
||||
// if so, create a copy and lower-case the keys recursively.
|
||||
func toCaseInsensitiveValue(value interface{}) interface{} {
|
||||
|
|
2
viper.go
2
viper.go
|
@ -1700,7 +1700,7 @@ func (v *Viper) unmarshalReader(in io.Reader, c map[string]interface{}) error {
|
|||
case "yaml", "yml", "json", "toml", "hcl", "tfvars", "ini", "properties", "props", "prop", "dotenv", "env":
|
||||
err := v.decoderRegistry.Decode(format, buf.Bytes(), c)
|
||||
if err != nil {
|
||||
return ConfigParseError{err}
|
||||
return &ConfigParseError{err}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue