TUN-3516: Better error message when parsing invalid YAML config
This commit is contained in:
parent
61c814bd79
commit
87e2679744
|
@ -1,7 +1,6 @@
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -9,6 +8,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
homedir "github.com/mitchellh/go-homedir"
|
homedir "github.com/mitchellh/go-homedir"
|
||||||
|
"github.com/pkg/errors"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
|
|
||||||
|
@ -391,7 +391,7 @@ func ReadConfigFile(c *cli.Context, log logger.Service) (*configFileSettings, er
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
if err := yaml.NewDecoder(file).Decode(&configuration); err != nil {
|
if err := yaml.NewDecoder(file).Decode(&configuration); err != nil {
|
||||||
return nil, err
|
return nil, errors.Wrap(err, "error parsing config file at "+configFile)
|
||||||
}
|
}
|
||||||
configuration.sourceFile = configFile
|
configuration.sourceFile = configFile
|
||||||
return &configuration, nil
|
return &configuration, nil
|
||||||
|
|
Loading…
Reference in New Issue