TUN-3516: Better error message when parsing invalid YAML config

This commit is contained in:
Adam Chalmers 2020-11-09 10:32:47 -06:00
parent 61c814bd79
commit 87e2679744
1 changed files with 2 additions and 2 deletions

View File

@ -1,7 +1,6 @@
package config
import (
"errors"
"fmt"
"os"
"path/filepath"
@ -9,6 +8,7 @@ import (
"time"
homedir "github.com/mitchellh/go-homedir"
"github.com/pkg/errors"
"github.com/urfave/cli/v2"
"gopkg.in/yaml.v2"
@ -391,7 +391,7 @@ func ReadConfigFile(c *cli.Context, log logger.Service) (*configFileSettings, er
}
defer file.Close()
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
return &configuration, nil