herrors: Improve handling of JSON errors
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 23 Oct 2018 06:54:10 +0000 (08:54 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 23 Oct 2018 12:35:43 +0000 (14:35 +0200)
commitf669ef6bec25155d015b6ab231c53caef4fa5cdc
treea76f3843a7249ccbc61ec6c8a20ac2c38e8518cc
parented7b3e261909fe425ef64216f12806840c45b205
herrors: Improve handling of JSON errors

`*json.UnmarshalTypeError` and `*json.SyntaxError` has a byte `Offset`, so use that.

This commit also reworks/simplifies the errror line matching logic. This also makes the file reading unbuffered, but that should be fine in this error case.

See #5324
common/herrors/error_locator.go
common/herrors/error_locator_test.go
common/herrors/file_error.go
common/herrors/file_error_test.go
go.sum
hugolib/hugo_sites.go
hugolib/hugo_sites_build_errors_test.go
hugolib/page_content.go
parser/metadecoders/decoder.go
tpl/template.go