Merge pull request #13796 from y-zeng/cli_token

Report more error messages in grpc_cli
pull/15690/head
Yang Gao 7 years ago committed by GitHub
commit 045e4f9889
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 28
      test/cpp/util/grpc_tool.cc

@ -471,17 +471,26 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
std::shared_ptr<grpc::Channel> channel = std::shared_ptr<grpc::Channel> channel =
grpc::CreateChannel(server_address, cred.GetCredentials()); grpc::CreateChannel(server_address, cred.GetCredentials());
parser.reset(new grpc::testing::ProtoFileParser( if (!FLAGS_binary_input || !FLAGS_binary_output) {
FLAGS_remotedb ? channel : nullptr, FLAGS_proto_path, FLAGS_protofiles)); 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) { if (FLAGS_binary_input) {
formatted_method_name = method_name; formatted_method_name = method_name;
} else { } else {
formatted_method_name = parser->GetFormattedMethodName(method_name); formatted_method_name = parser->GetFormattedMethodName(method_name);
} if (parser->HasError()) {
fprintf(stderr, "Failed to find method %s in proto files.\n",
if (parser->HasError()) { method_name.c_str());
return false; }
} }
if (argc == 3) { if (argc == 3) {
@ -711,6 +720,7 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
serialized_request_proto = parser->GetSerializedProtoFromMethod( serialized_request_proto = parser->GetSerializedProtoFromMethod(
method_name, request_text, true /* is_request */); method_name, request_text, true /* is_request */);
if (parser->HasError()) { if (parser->HasError()) {
fprintf(stderr, "Failed to parse request.\n");
return false; return false;
} }
} }
@ -735,6 +745,7 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
serialized_response_proto = parser->GetTextFormatFromMethod( serialized_response_proto = parser->GetTextFormatFromMethod(
method_name, serialized_response_proto, false /* is_request */); method_name, serialized_response_proto, false /* is_request */);
if (parser->HasError()) { if (parser->HasError()) {
fprintf(stderr, "Failed to parse response.\n");
return false; return false;
} }
} }
@ -814,6 +825,9 @@ bool GrpcTool::ParseMessage(int argc, const char** argv,
new grpc::testing::ProtoFileParser(FLAGS_remotedb ? channel : nullptr, new grpc::testing::ProtoFileParser(FLAGS_remotedb ? channel : nullptr,
FLAGS_proto_path, FLAGS_protofiles)); FLAGS_proto_path, FLAGS_protofiles));
if (parser->HasError()) { if (parser->HasError()) {
fprintf(
stderr,
"Failed to find remote reflection service and local proto files.\n");
return false; return false;
} }
} }
@ -824,6 +838,7 @@ bool GrpcTool::ParseMessage(int argc, const char** argv,
serialized_request_proto = serialized_request_proto =
parser->GetSerializedProtoFromMessageType(type_name, message_text); parser->GetSerializedProtoFromMessageType(type_name, message_text);
if (parser->HasError()) { if (parser->HasError()) {
fprintf(stderr, "Failed to serialize the message.\n");
return false; return false;
} }
} }
@ -834,6 +849,7 @@ bool GrpcTool::ParseMessage(int argc, const char** argv,
grpc::string output_text = parser->GetTextFormatFromMessageType( grpc::string output_text = parser->GetTextFormatFromMessageType(
type_name, serialized_request_proto); type_name, serialized_request_proto);
if (parser->HasError()) { if (parser->HasError()) {
fprintf(stderr, "Failed to deserialize the message.\n");
return false; return false;
} }
output_ss << output_text << std::endl; output_ss << output_text << std::endl;

Loading…
Cancel
Save