Browse Source

codec: propagate Flush() errors at end of encode

This was keeping Write() errors from being exposed to the caller.
Allen Luce 7 years ago
parent
commit
b5b9495648
1 changed files with 3 additions and 1 deletions
  1. 3 1
      codec/encode.go

+ 3 - 1
codec/encode.go

@@ -219,7 +219,9 @@ func (z *ioEncWriter) writen2(b1, b2 byte) {
 
 
 func (z *ioEncWriter) atEndOfEncode() {
 func (z *ioEncWriter) atEndOfEncode() {
 	if z.fw != nil {
 	if z.fw != nil {
-		z.fw.Flush()
+		if err := z.fw.Flush(); err != nil {
+			panic(err)
+		}
 	}
 	}
 }
 }