|
@@ -43,11 +43,6 @@ import (
|
|
|
"reflect"
|
|
"reflect"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
-// ErrWrongType occurs when the wire encoding for the field disagrees with
|
|
|
|
|
-// that specified in the type being decoded. This is usually caused by attempting
|
|
|
|
|
-// to convert an encoded protocol buffer into a struct of the wrong type.
|
|
|
|
|
-var ErrWrongType = errors.New("proto: field/encoding mismatch: wrong type for field")
|
|
|
|
|
-
|
|
|
|
|
// errOverflow is returned when an integer is too large to be represented.
|
|
// errOverflow is returned when an integer is too large to be represented.
|
|
|
var errOverflow = errors.New("proto: integer overflow")
|
|
var errOverflow = errors.New("proto: integer overflow")
|
|
|
|
|
|
|
@@ -363,11 +358,11 @@ func (o *Buffer) unmarshalType(st reflect.Type, prop *StructProperties, is_group
|
|
|
if is_group {
|
|
if is_group {
|
|
|
return nil // input is satisfied
|
|
return nil // input is satisfied
|
|
|
}
|
|
}
|
|
|
- return ErrWrongType
|
|
|
|
|
|
|
+ return fmt.Errorf("proto: %s: wiretype end group for non-group", st)
|
|
|
}
|
|
}
|
|
|
tag := int(u >> 3)
|
|
tag := int(u >> 3)
|
|
|
if tag <= 0 {
|
|
if tag <= 0 {
|
|
|
- return fmt.Errorf("proto: illegal tag %d", tag)
|
|
|
|
|
|
|
+ return fmt.Errorf("proto: %s: illegal tag %d", st, tag)
|
|
|
}
|
|
}
|
|
|
fieldnum, ok := prop.decoderTags.get(tag)
|
|
fieldnum, ok := prop.decoderTags.get(tag)
|
|
|
if !ok {
|
|
if !ok {
|
|
@@ -397,7 +392,7 @@ func (o *Buffer) unmarshalType(st reflect.Type, prop *StructProperties, is_group
|
|
|
// a packable field
|
|
// a packable field
|
|
|
dec = p.packedDec
|
|
dec = p.packedDec
|
|
|
} else {
|
|
} else {
|
|
|
- err = ErrWrongType
|
|
|
|
|
|
|
+ err = fmt.Errorf("proto: bad wiretype for field %s.%s: got wiretype %d, want %d", st, st.Field(fieldnum).Name, wire, p.WireType)
|
|
|
continue
|
|
continue
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|