goprotobuf: update to new errors.
Mostly gofix, but a few needed hand-work,
such as in the generator.
R=r, bradfitz, rsc
CC=golang-dev
http://codereview.appspot.com/5335045
diff --git a/proto/all_test.go b/proto/all_test.go
index 78181fd..4b29b27 100644
--- a/proto/all_test.go
+++ b/proto/all_test.go
@@ -37,7 +37,6 @@
"fmt"
"json"
"math"
- "os"
"reflect"
"strings"
"testing"
@@ -430,7 +429,7 @@
err := o.Marshal(pb)
if err == nil {
t.Error("did not catch missing required fields")
- } else if strings.Index(err.String(), "GoTest") < 0 {
+ } else if strings.Index(err.Error(), "GoTest") < 0 {
t.Error("wrong error type:", err)
}
}
@@ -845,22 +844,22 @@
d, err := Marshal(pb)
if err != nil {
- t.Errorf(err.String())
+ t.Error(err)
}
pbd := new(GoTest)
if err := Unmarshal(d, pbd); err != nil {
- t.Errorf(err.String())
+ t.Error(err)
}
if pbd.F_BytesRequired == nil || len(pbd.F_BytesRequired) != 0 {
- t.Errorf("required empty bytes field is incorrect")
+ t.Error("required empty bytes field is incorrect")
}
if pbd.F_BytesRepeated == nil || len(pbd.F_BytesRepeated) == 1 && pbd.F_BytesRepeated[0] == nil {
- t.Errorf("repeated empty bytes field is incorrect")
+ t.Error("repeated empty bytes field is incorrect")
}
if pbd.F_BytesOptional == nil || len(pbd.F_BytesOptional) != 0 {
- t.Errorf("optional empty bytes field is incorrect")
+ t.Error("optional empty bytes field is incorrect")
}
}
@@ -874,16 +873,16 @@
d, err := Marshal(pb)
if err != nil {
- t.Errorf(err.String())
+ t.Error(err)
}
pbd := new(GoTest)
if err := Unmarshal(d, pbd); err != nil {
- t.Errorf(err.String())
+ t.Error(err)
}
if len(pbd.F_BytesRepeated) != 1 || pbd.F_BytesRepeated[0] == nil {
- t.Errorf("Unexpected value for repeated bytes field")
+ t.Error("Unexpected value for repeated bytes field")
}
}
@@ -1155,7 +1154,7 @@
_, err := Marshal(pb)
if err == nil {
t.Error("marshal: expected error, got nil")
- } else if strings.Index(err.String(), "GoTestField") < 0 {
+ } else if strings.Index(err.Error(), "GoTestField") < 0 {
t.Errorf("marshal: bad error type: %v", err)
}
@@ -1166,7 +1165,7 @@
err = Unmarshal(buf, pb)
if err == nil {
t.Error("unmarshal: expected error, got nil")
- } else if strings.Index(err.String(), "GoTestField") < 0 {
+ } else if strings.Index(err.Error(), "GoTestField") < 0 {
t.Errorf("unmarshal: bad error type: %v", err)
}
}
@@ -1174,7 +1173,7 @@
// A type that implements the Marshaler interface, but is not nillable.
type nonNillableInt uint64
-func (nni nonNillableInt) Marshal() ([]byte, os.Error) {
+func (nni nonNillableInt) Marshal() ([]byte, error) {
return EncodeVarint(uint64(nni)), nil
}
@@ -1187,7 +1186,7 @@
x uint64
}
-func (nm *nillableMessage) Marshal() ([]byte, os.Error) {
+func (nm *nillableMessage) Marshal() ([]byte, error) {
return EncodeVarint(nm.x), nil
}