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
This commit is contained in:
Bjørn Erik Pedersen
2018-10-03 14:58:09 +02:00
parent 3a3089121b
commit 35fbfb19a1
73 changed files with 1914 additions and 668 deletions

9
deps/deps.go vendored
View File

@@ -16,7 +16,6 @@ import (
"github.com/gohugoio/hugo/resource"
"github.com/gohugoio/hugo/source"
"github.com/gohugoio/hugo/tpl"
jww "github.com/spf13/jwalterweatherman"
)
// Deps holds dependencies used by many.
@@ -25,7 +24,7 @@ import (
type Deps struct {
// The logger to use.
Log *jww.Notepad `json:"-"`
Log *loggers.Logger `json:"-"`
// Used to log errors that may repeat itself many times.
DistinctErrorLog *helpers.DistinctLogger
@@ -122,10 +121,6 @@ func (d *Deps) LoadResources() error {
return err
}
if th, ok := d.Tmpl.(tpl.TemplateHandler); ok {
th.PrintErrors()
}
return nil
}
@@ -256,7 +251,7 @@ func (d Deps) ForLanguage(cfg DepsCfg) (*Deps, error) {
type DepsCfg struct {
// The Logger to use.
Logger *jww.Notepad
Logger *loggers.Logger
// The file systems to use
Fs *hugofs.Fs