summaryrefslogtreecommitdiffstats
path: root/hugolib/site.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-05-02 16:07:52 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-05-06 19:43:22 +0200
commitf2946da9e806c2bafbdd26707fe339db79bd980b (patch)
treeb5609317a861ea5f399e094e1b9287ca71dc22d1 /hugolib/site.go
parent6eea32bd6bc8e7a7dd07a8cb6a8343ae2c74aba0 (diff)
Improve error messages, esp. when the server is running
* Add file context to minifier errors when publishing * Misc fixes (see issues) * Allow custom server error template in layouts/server/error.html To get to this, this commit also cleans up and simplifies the code surrounding errors and files. This also removes the usage of `github.com/pkg/errors`, mostly because of https://github.com/pkg/errors/issues/223 -- but also because most of this is now built-in to Go. Fixes #9852 Fixes #9857 Fixes #9863
Diffstat (limited to 'hugolib/site.go')
-rw-r--r--hugolib/site.go14
1 files changed, 6 insertions, 8 deletions
diff --git a/hugolib/site.go b/hugolib/site.go
index bbabf91a3..cf7f0ff82 100644
--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -59,8 +59,6 @@ import (
"github.com/gohugoio/hugo/common/hugo"
"github.com/gohugoio/hugo/publisher"
- "github.com/pkg/errors"
- _errors "github.com/pkg/errors"
"github.com/gohugoio/hugo/langs"
@@ -508,7 +506,7 @@ But this also means that your site configuration may not do what you expect. If
if cfg.Language.IsSet("related") {
relatedContentConfig, err = related.DecodeConfig(cfg.Language.GetParams("related"))
if err != nil {
- return nil, errors.Wrap(err, "failed to decode related config")
+ return nil, fmt.Errorf("failed to decode related config: %w", err)
}
} else {
relatedContentConfig = related.DefaultConfig
@@ -546,7 +544,7 @@ But this also means that your site configuration may not do what you expect. If
var err error
cascade, err := page.DecodeCascade(cfg.Language.Get("cascade"))
if err != nil {
- return nil, errors.Errorf("failed to decode cascade config: %s", err)
+ return nil, fmt.Errorf("failed to decode cascade config: %s", err)
}
siteBucket = &pagesMapBucket{
@@ -1211,11 +1209,11 @@ func (s *Site) processPartial(config *BuildCfg, init func(config *BuildCfg) erro
func (s *Site) process(config BuildCfg) (err error) {
if err = s.initialize(); err != nil {
- err = errors.Wrap(err, "initialize")
+ err = fmt.Errorf("initialize: %w", err)
return
}
if err = s.readAndProcessContent(config); err != nil {
- err = errors.Wrap(err, "readAndProcessContent")
+ err = fmt.Errorf("readAndProcessContent: %w", err)
return
}
return err
@@ -1534,7 +1532,7 @@ func (s *Site) assembleMenus() {
for name, me := range p.pageMenus.menus() {
if _, ok := flat[twoD{name, me.KeyName()}]; ok {
- err := p.wrapError(errors.Errorf("duplicate menu entry with identifier %q in menu %q", me.KeyName(), name))
+ err := p.wrapError(fmt.Errorf("duplicate menu entry with identifier %q in menu %q", me.KeyName(), name))
s.Log.Warnln(err)
continue
}
@@ -1819,7 +1817,7 @@ func (s *Site) renderForTemplate(name, outputFormat string, d any, w io.Writer,
}
if err = s.Tmpl().Execute(templ, w, d); err != nil {
- return _errors.Wrapf(err, "render of %q failed", name)
+ return fmt.Errorf("render of %q failed: %w", name, err)
}
return
}