summaryrefslogtreecommitdiffstats
path: root/hugolib/site.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-10-21 12:20:21 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-10-22 20:46:14 +0200
commitd1661b823af25c50d3bbe5366ea40a3cdd52e237 (patch)
treecd84d18229fb9c294ff1be56d7c0ce92a8f46761 /hugolib/site.go
parent7930d2132a3c36c1aaca20f16f56978c84656b0a (diff)
hugolib: Continue the file context/line number errors work
See #5324
Diffstat (limited to 'hugolib/site.go')
-rw-r--r--hugolib/site.go39
1 files changed, 2 insertions, 37 deletions
diff --git a/hugolib/site.go b/hugolib/site.go
index 8358cf610..78a0070ee 100644
--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -30,7 +30,6 @@ import (
_errors "github.com/pkg/errors"
- "github.com/gohugoio/hugo/common/herrors"
"github.com/gohugoio/hugo/common/maps"
"github.com/gohugoio/hugo/publisher"
"github.com/gohugoio/hugo/resource"
@@ -1552,7 +1551,7 @@ func (s *Site) preparePages() error {
}
}
- return s.pickOneAndLogTheRest(errors)
+ return s.owner.pickOneAndLogTheRest(errors)
}
func (s *Site) errorCollator(results <-chan error, errs chan<- error) {
@@ -1561,45 +1560,11 @@ func (s *Site) errorCollator(results <-chan error, errs chan<- error) {
errors = append(errors, e)
}
- errs <- s.pickOneAndLogTheRest(errors)
+ errs <- s.owner.pickOneAndLogTheRest(errors)
close(errs)
}
-func (s *Site) pickOneAndLogTheRest(errors []error) error {
- if len(errors) == 0 {
- return nil
- }
-
- var i int
-
- for j, err := range errors {
- // If this is in server mode, we want to return an error to the client
- // with a file context, if possible.
- if herrors.UnwrapErrorWithFileContext(err) != nil {
- i = j
- break
- }
- }
-
- // Log the rest, but add a threshold to avoid flooding the log.
- const errLogThreshold = 5
-
- for j, err := range errors {
- if j == i {
- continue
- }
-
- if j >= errLogThreshold {
- break
- }
-
- s.Log.ERROR.Println(err)
- }
-
- return errors[i]
-}
-
func (s *Site) appendThemeTemplates(in []string) []string {
if !s.PathSpec.ThemeSet() {
return in