Allow getJSON errors to be ignored

This change is mostly motivated to get a more stable CI build (we're building the Hugo site there, with Instagram and Twitter shortcodes sometimes failing).

Fixes #7866
This commit is contained in:
Bjørn Erik Pedersen
2020-10-21 11:17:48 +02:00
parent 8cbe2bbfad
commit fdfa4a5fe6
52 changed files with 318 additions and 221 deletions

14
deps/deps.go vendored
View File

@@ -21,6 +21,7 @@ import (
"github.com/gohugoio/hugo/resources"
"github.com/gohugoio/hugo/source"
"github.com/gohugoio/hugo/tpl"
"github.com/spf13/cast"
jww "github.com/spf13/jwalterweatherman"
)
@@ -30,7 +31,7 @@ import (
type Deps struct {
// The logger to use.
Log *loggers.Logger `json:"-"`
Log loggers.Logger `json:"-"`
// Used to log errors that may repeat itself many times.
DistinctErrorLog *helpers.DistinctLogger
@@ -260,12 +261,15 @@ func New(cfg DepsCfg) (*Deps, error) {
timeoutms = 3000
}
distinctErrorLogger := helpers.NewDistinctLogger(logger.ERROR)
distinctWarnLogger := helpers.NewDistinctLogger(logger.WARN)
ignoreErrors := cast.ToStringSlice(cfg.Cfg.Get("ignoreErrors"))
ignorableLogger := loggers.NewIgnorableLogger(logger, ignoreErrors...)
distinctErrorLogger := helpers.NewDistinctLogger(logger.Error())
distinctWarnLogger := helpers.NewDistinctLogger(logger.Warn())
d := &Deps{
Fs: fs,
Log: logger,
Log: ignorableLogger,
DistinctErrorLog: distinctErrorLogger,
DistinctWarningLog: distinctWarnLogger,
templateProvider: cfg.TemplateProvider,
@@ -350,7 +354,7 @@ func (d Deps) ForLanguage(cfg DepsCfg, onCreated func(d *Deps) error) (*Deps, er
type DepsCfg struct {
// The Logger to use.
Logger *loggers.Logger
Logger loggers.Logger
// The file systems to use
Fs *hugofs.Fs