From 6ac62118b76b5db52d2f1e387feadabf3f1bfbb5 Mon Sep 17 00:00:00 2001 From: Yuchen Zeng Date: Thu, 14 Dec 2017 19:12:42 -0800 Subject: [PATCH 1/2] Report more error messages in grpc_cli --- test/cpp/util/grpc_tool.cc | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/test/cpp/util/grpc_tool.cc b/test/cpp/util/grpc_tool.cc index 30c43b206f7..47b3094c9b5 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 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; From 33aaffa63968e9c35298c15447f469af9e17dbac Mon Sep 17 00:00:00 2001 From: Yuchen Zeng Date: Fri, 15 Dec 2017 11:03:50 -0800 Subject: [PATCH 2/2] clang_format --- test/cpp/util/grpc_tool.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/test/cpp/util/grpc_tool.cc b/test/cpp/util/grpc_tool.cc index 47b3094c9b5..4a27bf7414f 100644 --- a/test/cpp/util/grpc_tool.cc +++ b/test/cpp/util/grpc_tool.cc @@ -493,7 +493,6 @@ bool GrpcTool::CallMethod(int argc, const char** argv, } } - if (argc == 3) { request_text = argv[2]; }