Report serialization errors in conformance tests

This commit is contained in:
Jon Skeet 2016-01-15 10:55:57 +00:00
parent 888e71bdfc
commit c74676f070

View file

@ -105,15 +105,22 @@ namespace Google.Protobuf.Conformance
{
return new ConformanceResponse { ParseError = e.Message };
}
switch (request.RequestedOutputFormat)
try
{
case global::Conformance.WireFormat.JSON:
var formatter = new JsonFormatter(new JsonFormatter.Settings(false, typeRegistry));
return new ConformanceResponse { JsonPayload = formatter.Format(message) };
case global::Conformance.WireFormat.PROTOBUF:
return new ConformanceResponse { ProtobufPayload = message.ToByteString() };
default:
throw new Exception("Unsupported request output format: " + request.PayloadCase);
switch (request.RequestedOutputFormat)
{
case global::Conformance.WireFormat.JSON:
var formatter = new JsonFormatter(new JsonFormatter.Settings(false, typeRegistry));
return new ConformanceResponse { JsonPayload = formatter.Format(message) };
case global::Conformance.WireFormat.PROTOBUF:
return new ConformanceResponse { ProtobufPayload = message.ToByteString() };
default:
throw new Exception("Unsupported request output format: " + request.PayloadCase);
}
}
catch (InvalidOperationException e)
{
return new ConformanceResponse { SerializeError = e.Message };
}
}