aboutsummaryrefslogtreecommitdiffhomepage
path: root/csharp
diff options
context:
space:
mode:
authorGravatar Jon Skeet <jonskeet@google.com>2016-01-15 10:55:57 +0000
committerGravatar Jon Skeet <jonskeet@google.com>2016-01-15 10:55:57 +0000
commitc74676f07037acca34e9df0fb868b29afae15ac9 (patch)
tree07cf540192985fb70ee7a6d2ff7b22d9f006160b /csharp
parent888e71bdfc4918dbc16b62788c808cf415b7a8b0 (diff)
Report serialization errors in conformance tests
Diffstat (limited to 'csharp')
-rw-r--r--csharp/src/Google.Protobuf.Conformance/Program.cs23
1 files changed, 15 insertions, 8 deletions
diff --git a/csharp/src/Google.Protobuf.Conformance/Program.cs b/csharp/src/Google.Protobuf.Conformance/Program.cs
index c40851c6..f3f7e295 100644
--- a/csharp/src/Google.Protobuf.Conformance/Program.cs
+++ b/csharp/src/Google.Protobuf.Conformance/Program.cs
@@ -105,15 +105,22 @@ namespace Google.Protobuf.Conformance
{
return new ConformanceResponse { ParseError = e.Message };
}
- switch (request.RequestedOutputFormat)
+ try
+ {
+ 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)
{
- 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);
+ return new ConformanceResponse { SerializeError = e.Message };
}
}