summaryrefslogtreecommitdiff
path: root/errors.go
diff options
context:
space:
mode:
Diffstat (limited to 'errors.go')
-rw-r--r--errors.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/errors.go b/errors.go
index 0a47db4..516018c 100644
--- a/errors.go
+++ b/errors.go
@@ -121,6 +121,18 @@ func (e *DecodeError) Unwrap() error { return e.Err }
// encode errors ///////////////////////////////////////////////////////////////////////////////////
+// A EncodeWriteError is returned from Encode if there is an error
+// writing to the output stream.
+type EncodeWriteError struct {
+ Err error
+ Offset int64
+}
+
+func (e *EncodeWriteError) Error() string {
+ return fmt.Sprintf("json: I/O error at output byte %v: %v", e.Offset, e.Err)
+}
+func (e *EncodeWriteError) Unwrap() error { return e.Err }
+
// An EncodeTypeError is returned by Encode when attempting to encode
// an unsupported type.
//
@@ -155,6 +167,18 @@ func (e *EncodeMethodError) Unwrap() error { return e.Err }
// reencode errors /////////////////////////////////////////////////////////////////////////////////
+// A ReEncodeWriteError is returned from ReEncoder's methods if there
+// is an error writing to the output stream.
+type ReEncodeWriteError struct {
+ Err error
+ Offset int64
+}
+
+func (e *ReEncodeWriteError) Error() string {
+ return fmt.Sprintf("json: I/O error at output byte %v: %v", e.Offset, e.Err)
+}
+func (e *ReEncodeWriteError) Unwrap() error { return e.Err }
+
// A ReEncodeSyntaxError is returned from ReEncoder's methods if there
// is a syntax error in the input.
type ReEncodeSyntaxError struct {