aboutsummaryrefslogtreecommitdiffhomepage
path: root/deps
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2022-05-02 16:07:52 +0200
committerBjørn Erik Pedersen <[email protected]>2022-05-06 19:43:22 +0200
commitf2946da9e806c2bafbdd26707fe339db79bd980b (patch)
treeb5609317a861ea5f399e094e1b9287ca71dc22d1 /deps
parent6eea32bd6bc8e7a7dd07a8cb6a8343ae2c74aba0 (diff)
downloadhugo-f2946da9e806c2bafbdd26707fe339db79bd980b.tar.gz
hugo-f2946da9e806c2bafbdd26707fe339db79bd980b.zip
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 'deps')
-rw-r--r--deps/deps.go13
1 files changed, 6 insertions, 7 deletions
diff --git a/deps/deps.go b/deps/deps.go
index a9e78860d..ece420302 100644
--- a/deps/deps.go
+++ b/deps/deps.go
@@ -1,12 +1,11 @@
package deps
import (
+ "fmt"
"sync"
"sync/atomic"
"time"
- "github.com/pkg/errors"
-
"github.com/gohugoio/hugo/cache/filecache"
"github.com/gohugoio/hugo/common/hexec"
"github.com/gohugoio/hugo/common/loggers"
@@ -186,11 +185,11 @@ func (d *Deps) SetTextTmpl(tmpl tpl.TemplateParseFinder) {
func (d *Deps) LoadResources() error {
// Note that the translations need to be loaded before the templates.
if err := d.translationProvider.Update(d); err != nil {
- return errors.Wrap(err, "loading translations")
+ return fmt.Errorf("loading translations: %w", err)
}
if err := d.templateProvider.Update(d); err != nil {
- return errors.Wrap(err, "loading templates")
+ return fmt.Errorf("loading templates: %w", err)
}
return nil
@@ -236,18 +235,18 @@ func New(cfg DepsCfg) (*Deps, error) {
securityConfig, err := security.DecodeConfig(cfg.Cfg)
if err != nil {
- return nil, errors.WithMessage(err, "failed to create security config from configuration")
+ return nil, fmt.Errorf("failed to create security config from configuration: %w", err)
}
execHelper := hexec.New(securityConfig)
ps, err := helpers.NewPathSpec(fs, cfg.Language, logger)
if err != nil {
- return nil, errors.Wrap(err, "create PathSpec")
+ return nil, fmt.Errorf("create PathSpec: %w", err)
}
fileCaches, err := filecache.NewCaches(ps)
if err != nil {
- return nil, errors.WithMessage(err, "failed to create file caches from configuration")
+ return nil, fmt.Errorf("failed to create file caches from configuration: %w", err)
}
errorHandler := &globalErrHandler{}