diff options
author | Bjørn Erik Pedersen <[email protected]> | 2022-05-15 21:01:36 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2022-05-15 22:58:05 +0200 |
commit | 87a22eb6d609a65471ccf4de35a558e9669a4600 (patch) | |
tree | 229a520a61dac3c772104ab720613671d978f046 /hugolib/config.go | |
parent | fc9f315d86e1fe51c3d1eec3b60680113b2e3aa6 (diff) | |
download | hugo-87a22eb6d609a65471ccf4de35a558e9669a4600.tar.gz hugo-87a22eb6d609a65471ccf4de35a558e9669a4600.zip |
server: Fix SIGINT handling after loading bad configuration
Also fix the config error messages.
Fixes #9664
Diffstat (limited to 'hugolib/config.go')
-rw-r--r-- | hugolib/config.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/hugolib/config.go b/hugolib/config.go index e63d6da4e..ef23086b5 100644 --- a/hugolib/config.go +++ b/hugolib/config.go @@ -75,7 +75,7 @@ func LoadConfig(d ConfigSourceDescriptor, doWithConfig ...func(cfg config.Provid if err == nil { configFiles = append(configFiles, filename) } else if err != ErrNoConfigFile { - return nil, nil, err + return nil, nil, l.wrapFileError(err, filename) } } @@ -463,7 +463,7 @@ func (l configLoader) loadConfig(configName string) (string, error) { m, err := config.FromFileToMap(l.Fs, filename) if err != nil { - return "", l.wrapFileError(err, filename) + return filename, err } // Set overwrites keys of the same name, recursively. @@ -511,5 +511,12 @@ func (configLoader) loadSiteConfig(cfg config.Provider) (scfg SiteConfig, err er } func (l configLoader) wrapFileError(err error, filename string) error { + fe := herrors.UnwrapFileError(err) + if fe != nil { + pos := fe.Position() + pos.Filename = filename + fe.UpdatePosition(pos) + return err + } return herrors.NewFileErrorFromFile(err, filename, l.Fs, nil) } |