mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-18 21:11:19 +02:00
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
This commit is contained in:
@@ -23,11 +23,12 @@ import (
|
||||
"sync"
|
||||
"unicode/utf8"
|
||||
|
||||
"errors"
|
||||
|
||||
"github.com/gohugoio/hugo/common/text"
|
||||
"github.com/gohugoio/hugo/common/types/hstring"
|
||||
"github.com/gohugoio/hugo/identity"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cast"
|
||||
|
||||
"github.com/gohugoio/hugo/markup/converter/hooks"
|
||||
@@ -348,7 +349,7 @@ func (p *pageContentOutput) RenderString(args ...any) (template.HTML, error) {
|
||||
}
|
||||
|
||||
if err := mapstructure.WeakDecode(m, &opts); err != nil {
|
||||
return "", errors.WithMessage(err, "failed to decode options")
|
||||
return "", fmt.Errorf("failed to decode options: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,7 +417,7 @@ func (p *pageContentOutput) Render(layout ...string) (template.HTML, error) {
|
||||
// Make sure to send the *pageState and not the *pageContentOutput to the template.
|
||||
res, err := executeToString(p.p.s.Tmpl(), templ, p.p)
|
||||
if err != nil {
|
||||
return "", p.p.wrapError(errors.Wrapf(err, "failed to execute template %q v", layout))
|
||||
return "", p.p.wrapError(fmt.Errorf("failed to execute template %q v: %w", layout, err))
|
||||
}
|
||||
return template.HTML(res), nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user