Index: third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Program.cs |
diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Program.cs b/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Program.cs |
index 8f72c8f9b500a1a2a031196667bca2efb3f101d9..19827c4844587f444123580f5c6ac33cac8a29d5 100644 |
--- a/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Program.cs |
+++ b/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Program.cs |
@@ -101,15 +101,26 @@ namespace Google.Protobuf.Conformance |
{ |
return new ConformanceResponse { ParseError = e.Message }; |
} |
- switch (request.RequestedOutputFormat) |
+ catch (InvalidJsonException 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 { ParseError = e.Message }; |
+ } |
+ 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) |
+ { |
+ return new ConformanceResponse { SerializeError = e.Message }; |
} |
} |