github.com/segmentio/encoding@v0.4.0/proto/error.go (about) 1 package proto 2 3 import ( 4 "errors" 5 "fmt" 6 ) 7 8 var ( 9 ErrWireTypeUnknown = errors.New("unknown wire type") 10 ) 11 12 type UnmarshalFieldError struct { 13 FieldNumer int 14 WireType int 15 Err error 16 } 17 18 func (e *UnmarshalFieldError) Error() string { 19 return fmt.Sprintf("field number %d with wire type %d: %v", e.FieldNumer, e.WireType, e.Err) 20 } 21 22 func (e *UnmarshalFieldError) Unwrap() error { return e.Err } 23 24 func fieldError(f fieldNumber, t wireType, err error) error { 25 return &UnmarshalFieldError{ 26 FieldNumer: int(f), 27 WireType: int(t), 28 Err: err, 29 } 30 }