diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-10-23 09:54:10 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-10-23 15:35:43 +0300 |
commit | f669ef6bec25155d015b6ab231c53caef4fa5cdc (patch) | |
tree | a76f3843a7249ccbc61ec6c8a20ac2c38e8518cc /tpl/template.go | |
parent | ed7b3e261909fe425ef64216f12806840c45b205 (diff) |
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
Diffstat (limited to 'tpl/template.go')
-rw-r--r-- | tpl/template.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tpl/template.go b/tpl/template.go index 09710206e..12a4607fb 100644 --- a/tpl/template.go +++ b/tpl/template.go @@ -162,18 +162,18 @@ func (t *TemplateAdapter) addFileContext(name string, inerr error) error { // Since this can be a composite of multiple template files (single.html + baseof.html etc.) // we potentially need to look in both -- and cannot rely on line number alone. - lineMatcher := func(le herrors.FileError, lineNumber int, line string) bool { - if le.LineNumber() != lineNumber { + lineMatcher := func(m herrors.LineMatcher) bool { + if m.FileError.LineNumber() != m.LineNumber { return false } if !hasMaster { return true } - identifiers := t.extractIdentifiers(le.Error()) + identifiers := t.extractIdentifiers(m.FileError.Error()) for _, id := range identifiers { - if strings.Contains(line, id) { + if strings.Contains(m.Line, id) { return true } } |