summaryrefslogtreecommitdiff
path: root/encode.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-02-10 21:56:11 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2023-02-10 21:56:11 -0700
commitd7414035894f378c9e1d48b04a767f61b082186a (patch)
treeba9ec20307b4200f1010bc291d78c3786b57e326 /encode.go
parentc604347f1950e3dfbef2f524da8a63692848da27 (diff)
parent276ab5935873edc05e1882c06fc527a14babd27c (diff)
Merge branch 'lukeshu/reencode-io'
Diffstat (limited to 'encode.go')
-rw-r--r--encode.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/encode.go b/encode.go
index b6541cd..d39c862 100644
--- a/encode.go
+++ b/encode.go
@@ -83,6 +83,12 @@ func (enc *Encoder) Encode(obj any) (err error) {
enc.w.par.Reset()
}
if err := encode(enc.w, reflect.ValueOf(obj), enc.w.BackslashEscape, false, 0, map[any]struct{}{}); err != nil {
+ if rwe, ok := err.(*ReEncodeWriteError); ok {
+ err = &EncodeWriteError{
+ Err: rwe.Err,
+ Offset: rwe.Offset,
+ }
+ }
return err
}
if enc.isRoot {