diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-10-22 16:47:23 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-10-22 20:46:14 +0200 |
commit | 9f74dc2a52b6f568b5a060b7a4be47196804b01f (patch) | |
tree | c0f3ddff1103d7244a02f14ba9b862cf5593dced /hugolib | |
parent | d1661b823af25c50d3bbe5366ea40a3cdd52e237 (diff) |
hugolib: Improve errors in /data handlling
See #5324
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/site.go | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/hugolib/site.go b/hugolib/site.go index 78a0070ee..e3f6d8f8c 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -28,6 +28,10 @@ import ( "strings" "time" + "github.com/gohugoio/hugo/hugofs" + + "github.com/gohugoio/hugo/common/herrors" + _errors "github.com/pkg/errors" "github.com/gohugoio/hugo/common/maps" @@ -776,7 +780,7 @@ func (s *Site) processPartial(events []fsnotify.Event) (whatChanged, error) { if len(dataChanged) > 0 { if err := s.readDataFromSourceFS(); err != nil { - s.Log.ERROR.Println(err) + return whatChanged{}, err } } @@ -884,8 +888,14 @@ func (s *Site) handleDataFile(r source.ReadableFile) error { data, err := s.readData(r) if err != nil { - s.Log.ERROR.Printf("Failed to read data from %s: %s", filepath.Join(r.Path(), r.LogicalName()), err) - return nil + realFilename := r.FileInfo().(hugofs.RealFilenameInfo).RealFilename() + err, _ = herrors.WithFileContextForFile( + _errors.Wrapf(err, "failed to read data file"), + realFilename, + realFilename, + s.SourceSpec.Fs.Source, + herrors.SimpleLineMatcher) + return err } if data == nil { |