aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cpp
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2015-08-17 13:59:07 -0700
committerGravatar Vijay Pai <vpai@google.com>2015-08-17 13:59:07 -0700
commit2461bf675ec23f513569a14933609f09b4ff3854 (patch)
treebb0698ac7dfb997ca31384992ff7de453fb487c6 /src/cpp
parentd6225ee6eb8e7cd57e9fa5a5d15f0b755255ee5d (diff)
parentf99c090625bc1963468d2df24a7503298cfd53b2 (diff)
Merge pull request #2907 from yang-g/error_code_conforming
return StatusCode::INTERNAL for proto parsing error
Diffstat (limited to 'src/cpp')
-rw-r--r--src/cpp/proto/proto_utils.cc9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/cpp/proto/proto_utils.cc b/src/cpp/proto/proto_utils.cc
index 63f4a3a0bc..94ae5ba636 100644
--- a/src/cpp/proto/proto_utils.cc
+++ b/src/cpp/proto/proto_utils.cc
@@ -158,14 +158,13 @@ Status SerializeProto(const grpc::protobuf::Message& msg, grpc_byte_buffer** bp)
GrpcBufferWriter writer(bp);
return msg.SerializeToZeroCopyStream(&writer)
? Status::OK
- : Status(StatusCode::INVALID_ARGUMENT,
- "Failed to serialize message");
+ : Status(StatusCode::INTERNAL, "Failed to serialize message");
}
Status DeserializeProto(grpc_byte_buffer* buffer, grpc::protobuf::Message* msg,
int max_message_size) {
if (!buffer) {
- return Status(StatusCode::INVALID_ARGUMENT, "No payload");
+ return Status(StatusCode::INTERNAL, "No payload");
}
GrpcBufferReader reader(buffer);
::grpc::protobuf::io::CodedInputStream decoder(&reader);
@@ -173,11 +172,11 @@ Status DeserializeProto(grpc_byte_buffer* buffer, grpc::protobuf::Message* msg,
decoder.SetTotalBytesLimit(max_message_size, max_message_size);
}
if (!msg->ParseFromCodedStream(&decoder)) {
- return Status(StatusCode::INVALID_ARGUMENT,
+ return Status(StatusCode::INTERNAL,
msg->InitializationErrorString());
}
if (!decoder.ConsumedEntireMessage()) {
- return Status(StatusCode::INVALID_ARGUMENT, "Did not read entire message");
+ return Status(StatusCode::INTERNAL, "Did not read entire message");
}
return Status::OK;
}