diff options
author | Jon Skeet <jonskeet@google.com> | 2016-01-15 10:55:57 +0000 |
---|---|---|
committer | Jon Skeet <jonskeet@google.com> | 2016-01-15 10:55:57 +0000 |
commit | c74676f07037acca34e9df0fb868b29afae15ac9 (patch) | |
tree | 07cf540192985fb70ee7a6d2ff7b22d9f006160b /csharp | |
parent | 888e71bdfc4918dbc16b62788c808cf415b7a8b0 (diff) |
Report serialization errors in conformance tests
Diffstat (limited to 'csharp')
-rw-r--r-- | csharp/src/Google.Protobuf.Conformance/Program.cs | 23 |
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 }; } } |