aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/util
diff options
context:
space:
mode:
authorGravatar Yuchen Zeng <zyc@google.com>2017-12-14 19:12:42 -0800
committerGravatar Yuchen Zeng <zyc@google.com>2017-12-14 19:12:42 -0800
commit6ac62118b76b5db52d2f1e387feadabf3f1bfbb5 (patch)
tree9aec6324f16870e51fb63ed46e46698121f9db2a /test/cpp/util
parent487ee31b9e2504ad0208ce3b0f6a0c0f405a3605 (diff)
Report more error messages in grpc_cli
Diffstat (limited to 'test/cpp/util')
-rw-r--r--test/cpp/util/grpc_tool.cc27
1 files changed, 22 insertions, 5 deletions
diff --git a/test/cpp/util/grpc_tool.cc b/test/cpp/util/grpc_tool.cc
index 30c43b206f..47b3094c9b 100644
--- a/test/cpp/util/grpc_tool.cc
+++ b/test/cpp/util/grpc_tool.cc
@@ -471,18 +471,28 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
std::shared_ptr<grpc::Channel> channel =
grpc::CreateChannel(server_address, cred.GetCredentials());
- parser.reset(new grpc::testing::ProtoFileParser(
- FLAGS_remotedb ? channel : nullptr, FLAGS_proto_path, FLAGS_protofiles));
+ if (!FLAGS_binary_input || !FLAGS_binary_output) {
+ parser.reset(
+ new grpc::testing::ProtoFileParser(FLAGS_remotedb ? channel : nullptr,
+ FLAGS_proto_path, FLAGS_protofiles));
+ if (parser->HasError()) {
+ fprintf(
+ stderr,
+ "Failed to find remote reflection service and local proto files.\n");
+ return false;
+ }
+ }
if (FLAGS_binary_input) {
formatted_method_name = method_name;
} else {
formatted_method_name = parser->GetFormattedMethodName(method_name);
+ if (parser->HasError()) {
+ fprintf(stderr, "Failed to find method %s in proto files.\n",
+ method_name.c_str());
+ }
}
- if (parser->HasError()) {
- return false;
- }
if (argc == 3) {
request_text = argv[2];
@@ -711,6 +721,7 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
serialized_request_proto = parser->GetSerializedProtoFromMethod(
method_name, request_text, true /* is_request */);
if (parser->HasError()) {
+ fprintf(stderr, "Failed to parse request.\n");
return false;
}
}
@@ -735,6 +746,7 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
serialized_response_proto = parser->GetTextFormatFromMethod(
method_name, serialized_response_proto, false /* is_request */);
if (parser->HasError()) {
+ fprintf(stderr, "Failed to parse response.\n");
return false;
}
}
@@ -812,6 +824,9 @@ bool GrpcTool::ParseMessage(int argc, const char** argv,
new grpc::testing::ProtoFileParser(FLAGS_remotedb ? channel : nullptr,
FLAGS_proto_path, FLAGS_protofiles));
if (parser->HasError()) {
+ fprintf(
+ stderr,
+ "Failed to find remote reflection service and local proto files.\n");
return false;
}
}
@@ -822,6 +837,7 @@ bool GrpcTool::ParseMessage(int argc, const char** argv,
serialized_request_proto =
parser->GetSerializedProtoFromMessageType(type_name, message_text);
if (parser->HasError()) {
+ fprintf(stderr, "Failed to serialize the message.\n");
return false;
}
}
@@ -832,6 +848,7 @@ bool GrpcTool::ParseMessage(int argc, const char** argv,
grpc::string output_text = parser->GetTextFormatFromMessageType(
type_name, serialized_request_proto);
if (parser->HasError()) {
+ fprintf(stderr, "Failed to deserialize the message.\n");
return false;
}
output_ss << output_text << std::endl;