goprotobuf: Rename ErrRequiredNotSet to RequiredNotSetError.
This then matches the standard Go style for error types.
R=r
CC=golang-dev
https://codereview.appspot.com/14007043
diff --git a/proto/all_test.go b/proto/all_test.go
index eec5841..9ae811e 100644
--- a/proto/all_test.go
+++ b/proto/all_test.go
@@ -1670,7 +1670,7 @@
}
}
-func TestErrRequiredNotSet(t *testing.T) {
+func TestRequiredNotSetError(t *testing.T) {
pb := initGoTest(false)
pb.RequiredField.Label = nil
pb.F_Int32Required = nil
@@ -1695,8 +1695,8 @@
o := old()
bytes, err := Marshal(pb)
- if _, ok := err.(*ErrRequiredNotSet); !ok {
- fmt.Printf("marshal-1 err = %v, want *ErrRequiredNotSet", err)
+ if _, ok := err.(*RequiredNotSetError); !ok {
+ fmt.Printf("marshal-1 err = %v, want *RequiredNotSetError", err)
o.DebugPrint("", bytes)
t.Fatalf("expected = %s", expected)
}
@@ -1711,8 +1711,8 @@
// Now test Unmarshal by recreating the original buffer.
pbd := new(GoTest)
err = Unmarshal(bytes, pbd)
- if _, ok := err.(*ErrRequiredNotSet); !ok {
- t.Fatalf("unmarshal err = %v, want *ErrRequiredNotSet", err)
+ if _, ok := err.(*RequiredNotSetError); !ok {
+ t.Fatalf("unmarshal err = %v, want *RequiredNotSetError", err)
o.DebugPrint("", bytes)
t.Fatalf("string = %s", expected)
}
@@ -1720,8 +1720,8 @@
t.Errorf("unmarshal wrong err msg: %v", err)
}
bytes, err = Marshal(pbd)
- if _, ok := err.(*ErrRequiredNotSet); !ok {
- t.Errorf("marshal-2 err = %v, want *ErrRequiredNotSet", err)
+ if _, ok := err.(*RequiredNotSetError); !ok {
+ t.Errorf("marshal-2 err = %v, want *RequiredNotSetError", err)
o.DebugPrint("", bytes)
t.Fatalf("string = %s", expected)
}
diff --git a/proto/decode.go b/proto/decode.go
index 3c58cfb..59189d7 100644
--- a/proto/decode.go
+++ b/proto/decode.go
@@ -441,7 +441,7 @@
// Not enough information to determine the exact field. If we use extra
// CPU, we could determine the field only if the missing required field
// has a tag <= 64 and we check reqFields.
- return &ErrRequiredNotSet{"{Unknown}"}
+ return &RequiredNotSetError{"{Unknown}"}
}
}
return err
diff --git a/proto/encode.go b/proto/encode.go
index 1cc62e9..2a249c8 100644
--- a/proto/encode.go
+++ b/proto/encode.go
@@ -42,20 +42,20 @@
"sort"
)
-// ErrRequiredNotSet is the error returned if Marshal is called with
+// RequiredNotSetError is the error returned if Marshal is called with
// a protocol buffer struct whose required fields have not
// all been initialized. It is also the error returned if Unmarshal is
// called with an encoded protocol buffer that does not include all the
// required fields.
//
-// When printed, ErrRequiredNotSet reports the first unset required field in a
+// When printed, RequiredNotSetError reports the first unset required field in a
// message. If the field cannot be precisely determined, it is reported as
// "{Unknown}".
-type ErrRequiredNotSet struct {
+type RequiredNotSetError struct {
field string
}
-func (e *ErrRequiredNotSet) Error() string {
+func (e *RequiredNotSetError) Error() string {
return fmt.Sprintf("proto: required field %q not set", e.field)
}
@@ -590,7 +590,7 @@
if err != nil {
if err == ErrNil {
if p.Required && state.err == nil {
- state.err = &ErrRequiredNotSet{p.Name}
+ state.err = &RequiredNotSetError{p.Name}
}
} else if !state.shouldContinue(err, p) {
return err
@@ -617,7 +617,7 @@
}
// shouldContinue reports whether encoding should continue upon encountering the
-// given error. If the error is ErrRequiredNotSet, shouldContinue returns true
+// given error. If the error is RequiredNotSetError, shouldContinue returns true
// and, if this is the first appearance of that error, remembers it for future
// reporting.
//
@@ -625,13 +625,13 @@
// field with the error.
func (s *errorState) shouldContinue(err error, prop *Properties) bool {
// Ignore unset required fields.
- reqNotSet, ok := err.(*ErrRequiredNotSet)
+ reqNotSet, ok := err.(*RequiredNotSetError)
if !ok {
return false
}
if s.err == nil {
if prop != nil {
- err = &ErrRequiredNotSet{prop.Name + "." + reqNotSet.field}
+ err = &RequiredNotSetError{prop.Name + "." + reqNotSet.field}
}
s.err = err
}