]> Cypherpunks repositories - gostls13.git/commitdiff
gob: split uses of gobError, remove unnecessary embedding
authorRuss Cox <rsc@golang.org>
Fri, 28 Oct 2011 03:20:59 +0000 (20:20 -0700)
committerRuss Cox <rsc@golang.org>
Fri, 28 Oct 2011 03:20:59 +0000 (20:20 -0700)
Will make gofix for error run more smoothly.
The overloading of gobError appears to be unintentional.

R=r
CC=golang-dev
https://golang.org/cl/5308060

src/pkg/gob/codec_test.go
src/pkg/gob/decoder.go
src/pkg/gob/error.go

index 2bcbf82a3093c8b85ad00a0cb019ef8b9adf3772..5306354bf2a1c91b6d405161aa2250b1c5883e43 100644 (file)
@@ -41,7 +41,7 @@ var encodeT = []EncodeT{
 // plain test.Error call.
 func testError(t *testing.T) {
        if e := recover(); e != nil {
-               t.Error(e.(gobError).Error) // Will re-panic if not one of our errors, such as a runtime error.
+               t.Error(e.(gobError).err) // Will re-panic if not one of our errors, such as a runtime error.
        }
        return
 }
index 5efcea8bc16f6a1965323597d15ea4a502067343..1d526e35c0f918baad25a6df52758cc548b63ffe 100644 (file)
@@ -64,7 +64,7 @@ func (dec *Decoder) recvType(id typeId) {
        dec.wireType[id] = wire
 }
 
-var errBadCount = gobError{os.NewError("invalid message length")}
+var errBadCount = os.NewError("invalid message length")
 
 // recvMessage reads the next count-delimited item from the input. It is the converse
 // of Encoder.writeMessage. It returns false on EOF or other error reading the message.
index bfd38fc16d392b0b605a228db7949a310c47418e..106543d736031a4a5bf5c6846dde4834bdfca198 100644 (file)
@@ -18,7 +18,7 @@ import (
 
 // A gobError wraps an os.Error and is used to distinguish errors (panics) generated in this package.
 type gobError struct {
-       os.Error
+       err os.Error
 }
 
 // errorf is like error but takes Printf-style arguments to construct an os.Error.
@@ -29,14 +29,14 @@ func errorf(format string, args ...interface{}) {
 
 // error wraps the argument error and uses it as the argument to panic.
 func error(err os.Error) {
-       panic(gobError{Error: err})
+       panic(gobError{err})
 }
 
 // catchError is meant to be used as a deferred function to turn a panic(gobError) into a
 // plain os.Error.  It overwrites the error return of the function that deferred its call.
 func catchError(err *os.Error) {
        if e := recover(); e != nil {
-               *err = e.(gobError).Error // Will re-panic if not one of our errors, such as a runtime error.
+               *err = e.(gobError).err // Will re-panic if not one of our errors, such as a runtime error.
        }
        return
 }