diff options
author | Luke Shumaker <lukeshu@datawire.io> | 2022-08-15 21:25:06 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@datawire.io> | 2022-08-16 00:05:37 -0600 |
commit | 67b78f25f76b8ca43d837fb8055ca8e2b06c7d02 (patch) | |
tree | 517343e316a24cb2f07b16d23ccbf04570f4ce7c /reencode.go | |
parent | 6476b9ae7019bedd9324786ff47bc25693e01b60 (diff) |
Get borrowed_scanner_test.go passing [ci-skip]
Diffstat (limited to 'reencode.go')
-rw-r--r-- | reencode.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/reencode.go b/reencode.go index 92e870a..bb0dc24 100644 --- a/reencode.go +++ b/reencode.go @@ -79,7 +79,7 @@ func (enc *ReEncoder) Write(p []byte) (int, error) { func (enc *ReEncoder) Close() error { if enc.bufLen > 0 { - return &DecodeSyntaxError{ + return &ReEncodeSyntaxError{ Offset: enc.inputPos, Err: fmt.Errorf("%w: unflushed unicode garbage: %q", io.ErrUnexpectedEOF, enc.buf[:enc.bufLen]), } @@ -111,7 +111,10 @@ func (enc *ReEncoder) WriteRune(c rune) (n int, err error) { } t, err := enc.par.HandleRune(c) if err != nil { - enc.err = err + enc.err = &ReEncodeSyntaxError{ + Err: err, + Offset: enc.inputPos, + } return 0, enc.err } @@ -178,7 +181,7 @@ func (enc *ReEncoder) handleRune(c rune, t RuneType) error { case RuneTypeObjectEnd, RuneTypeArrayEnd: enc.curIndent-- switch enc.lastNonSpace { - case RuneTypeObjectBeg, RuneTypeArrayEnd: + case RuneTypeObjectBeg, RuneTypeArrayBeg: // collapse default: if err := enc.emitNlIndent(); err != nil { |