diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-10-03 14:58:09 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-10-16 22:10:56 +0200 |
commit | 35fbfb19a173b01bc881f2bbc5d104136633a7ec (patch) | |
tree | 636d0d51fa262dc808eb3c5cc9cf92ad977a0c6a /resource/resource.go | |
parent | 3a3089121b852332b5744d1f566959c8cf93cef4 (diff) |
commands: Show server error info in browser
The main item in this commit is showing of errors with a file context when running `hugo server`.
This can be turned off: `hugo server --disableBrowserError` (can also be set in `config.toml`).
But to get there, the error handling in Hugo needed a revision. There are some items left TODO for commits soon to follow, most notable errors in content and config files.
Fixes #5284
Fixes #5290
See #5325
See #5324
Diffstat (limited to 'resource/resource.go')
-rw-r--r-- | resource/resource.go | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/resource/resource.go b/resource/resource.go index dd9cbbd41..be3ebdb8b 100644 --- a/resource/resource.go +++ b/resource/resource.go @@ -14,7 +14,6 @@ package resource import ( - "errors" "fmt" "io" "io/ioutil" @@ -27,13 +26,12 @@ import ( "github.com/gohugoio/hugo/output" "github.com/gohugoio/hugo/tpl" + "github.com/pkg/errors" "github.com/gohugoio/hugo/common/collections" "github.com/gohugoio/hugo/common/hugio" "github.com/gohugoio/hugo/common/loggers" - jww "github.com/spf13/jwalterweatherman" - "github.com/spf13/afero" "github.com/gobwas/glob" @@ -273,7 +271,7 @@ type Spec struct { MediaTypes media.Types OutputFormats output.Formats - Logger *jww.Notepad + Logger *loggers.Logger TextTemplates tpl.TemplateParseFinder @@ -287,7 +285,7 @@ type Spec struct { GenAssetsPath string } -func NewSpec(s *helpers.PathSpec, logger *jww.Notepad, outputFormats output.Formats, mimeTypes media.Types) (*Spec, error) { +func NewSpec(s *helpers.PathSpec, logger *loggers.Logger, outputFormats output.Formats, mimeTypes media.Types) (*Spec, error) { imaging, err := decodeImaging(s.Cfg.GetStringMap("imaging")) if err != nil { @@ -542,7 +540,7 @@ type resourceHash struct { type publishOnce struct { publisherInit sync.Once publisherErr error - logger *jww.Notepad + logger *loggers.Logger } func (l *publishOnce) publish(s Source) error { @@ -660,7 +658,7 @@ func (l *genericResource) initHash() error { var f hugio.ReadSeekCloser f, err = l.ReadSeekCloser() if err != nil { - err = fmt.Errorf("failed to open source file: %s", err) + err = errors.Wrap(err, "failed to open source file") return } defer f.Close() |