Преглед на файлове

encoding: add TODOs for producing better error messages with handling of Any

Change-Id: Iaab531d8ae454715338bf079a2749afeedc978f9
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/175577
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Herbie Ong преди 6 години
родител
ревизия
9c1004563f
променени са 3 файла, в които са добавени 12 реда и са изтрити 0 реда
  1. 6 0
      encoding/jsonpb/well_known_types.go
  2. 3 0
      encoding/textpb/decode.go
  3. 3 0
      encoding/textpb/encode.go

+ 6 - 0
encoding/jsonpb/well_known_types.go

@@ -178,6 +178,9 @@ func (o MarshalOptions) marshalAny(m pref.Message) error {
 
 	em := emt.New()
 	// TODO: Need to set types registry in binary unmarshaling.
+	// TODO: If binary unmarshaling returns required not set error, need to
+	// return another required not set error that contains both the path to this
+	// field and the path inside the embedded message.
 	err = proto.UnmarshalOptions{
 		AllowPartial: o.AllowPartial,
 	}.Unmarshal(valueVal.Bytes(), em.Interface())
@@ -249,6 +252,9 @@ func (o UnmarshalOptions) unmarshalAny(m pref.Message) error {
 	}
 	// Serialize the embedded message and assign the resulting bytes to the
 	// proto value field.
+	// TODO: If binary marshaling returns required not set error, need to return
+	// another required not set error that contains both the path to this field
+	// and the path inside the embedded message.
 	b, err := proto.MarshalOptions{
 		AllowPartial:  o.AllowPartial,
 		Deterministic: true,

+ 3 - 0
encoding/textpb/decode.go

@@ -500,6 +500,9 @@ func (o UnmarshalOptions) unmarshalAny(tfield [2]text.Value, knownFields pref.Kn
 		return err
 	}
 	// Serialize the embedded message and assign the resulting bytes to the value field.
+	// TODO: If binary marshaling returns required not set error, need to
+	// return another required not set error that contains both the path to this
+	// field and the path inside the embedded message.
 	b, err := proto.MarshalOptions{
 		AllowPartial:  o.AllowPartial,
 		Deterministic: true,

+ 3 - 0
encoding/textpb/encode.go

@@ -362,6 +362,9 @@ func (o MarshalOptions) marshalAny(m pref.Message) (text.Value, error) {
 	}
 	em := emt.New().Interface()
 	// TODO: Need to set types registry in binary unmarshaling.
+	// TODO: If binary unmarshaling returns required not set error, need to
+	// return another required not set error that contains both the path to this
+	// field and the path inside the embedded message.
 	err = proto.UnmarshalOptions{
 		AllowPartial: o.AllowPartial,
 	}.Unmarshal(value.Bytes(), em)