Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/deps
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-10-21 13:20:21 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-10-22 21:46:14 +0300
commitd1661b823af25c50d3bbe5366ea40a3cdd52e237 (patch)
treecd84d18229fb9c294ff1be56d7c0ce92a8f46761 /deps
parent7930d2132a3c36c1aaca20f16f56978c84656b0a (diff)
hugolib: Continue the file context/line number errors work
See #5324
Diffstat (limited to 'deps')
-rw-r--r--deps/deps.go30
1 files changed, 29 insertions, 1 deletions
diff --git a/deps/deps.go b/deps/deps.go
index 1e2686421..db59ad212 100644
--- a/deps/deps.go
+++ b/deps/deps.go
@@ -5,7 +5,6 @@ import (
"time"
"github.com/gohugoio/hugo/common/loggers"
-
"github.com/gohugoio/hugo/config"
"github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/hugofs"
@@ -16,6 +15,7 @@ import (
"github.com/gohugoio/hugo/resource"
"github.com/gohugoio/hugo/source"
"github.com/gohugoio/hugo/tpl"
+ jww "github.com/spf13/jwalterweatherman"
)
// Deps holds dependencies used by many.
@@ -73,6 +73,33 @@ type Deps struct {
// BuildStartListeners will be notified before a build starts.
BuildStartListeners *Listeners
+
+ *globalErrHandler
+}
+
+type globalErrHandler struct {
+ // Channel for some "hard to get to" build errors
+ buildErrors chan error
+}
+
+// SendErr sends the error on a channel to be handled later.
+// This can be used in situations where returning and aborting the current
+// operation isn't practical.
+func (e *globalErrHandler) SendError(err error) {
+ if e.buildErrors != nil {
+ select {
+ case e.buildErrors <- err:
+ default:
+ }
+ return
+ }
+
+ jww.ERROR.Println(err)
+}
+
+func (e *globalErrHandler) StartErrorCollector() chan error {
+ e.buildErrors = make(chan error, 10)
+ return e.buildErrors
}
// Listeners represents an event listener.
@@ -194,6 +221,7 @@ func New(cfg DepsCfg) (*Deps, error) {
Language: cfg.Language,
BuildStartListeners: &Listeners{},
Timeout: time.Duration(timeoutms) * time.Millisecond,
+ globalErrHandler: &globalErrHandler{},
}
if cfg.Cfg.GetBool("templateMetrics") {