File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change 1515package schema
1616
1717import (
18+ "bufio"
1819 "encoding/json"
1920 "io"
20-
21- "go4.org/errorutil"
2221)
2322
2423// A SyntaxError is a description of a JSON syntax error
@@ -36,7 +35,21 @@ func (e *SyntaxError) Error() string { return e.msg }
3635// If the given error is not a *json.SyntaxError it is returned unchanged.
3736func WrapSyntaxError (r io.Reader , err error ) error {
3837 if serr , ok := err .(* json.SyntaxError ); ok {
39- line , col , _ := errorutil .HighlightBytePosition (r , serr .Offset )
38+ buf := bufio .NewReader (r )
39+ line := 0
40+ col := 0
41+ for i := int64 (0 ); i < serr .Offset ; i ++ {
42+ b , berr := buf .ReadByte ()
43+ if berr != nil {
44+ break
45+ }
46+ if b == '\n' {
47+ line ++
48+ col = 1
49+ } else {
50+ col ++
51+ }
52+ }
4053 return & SyntaxError {serr .Error (), line , col , serr .Offset }
4154 }
4255
You can’t perform that action at this time.
0 commit comments