diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-10 21:56:11 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-10 21:56:11 -0700 |
commit | d7414035894f378c9e1d48b04a767f61b082186a (patch) | |
tree | ba9ec20307b4200f1010bc291d78c3786b57e326 /reencode.go | |
parent | c604347f1950e3dfbef2f524da8a63692848da27 (diff) | |
parent | 276ab5935873edc05e1882c06fc527a14babd27c (diff) |
Merge branch 'lukeshu/reencode-io'
Diffstat (limited to 'reencode.go')
-rw-r--r-- | reencode.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/reencode.go b/reencode.go index e48c58c..d19dc1a 100644 --- a/reencode.go +++ b/reencode.go @@ -232,7 +232,7 @@ func (enc *ReEncoder) Close() error { } if len(enc.barriers) == 0 { if err := enc.handleRune(0, jsonparse.RuneTypeError, enc.stackSize()); err != nil { - enc.err = &ReEncodeSyntaxError{ + enc.err = &ReEncodeWriteError{ Err: err, Offset: enc.inputPos, } @@ -274,8 +274,14 @@ rehandle: } return enc.written, enc.err } - enc.err = enc.handleRune(c, t, enc.stackSize()) - if enc.err == nil && t == jsonparse.RuneTypeEOF { + if err := enc.handleRune(c, t, enc.stackSize()); err != nil { + enc.err = &ReEncodeWriteError{ + Err: err, + Offset: enc.inputPos, + } + return enc.written, enc.err + } + if t == jsonparse.RuneTypeEOF { if enc.AllowMultipleValues && len(enc.barriers) == 0 { enc.par.Reset() goto rehandle |