From b9cff78f9eaa2647a20813c03fe08199bdc8a668 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Mon, 4 Dec 2017 13:16:13 -0800 Subject: Reviewer feedback --- include/grpc++/impl/codegen/call.h | 22 +++++++++++++--------- include/grpc++/impl/codegen/client_context.h | 9 +++++++++ include/grpc++/impl/codegen/status.h | 13 ------------- 3 files changed, 22 insertions(+), 22 deletions(-) (limited to 'include/grpc++') diff --git a/include/grpc++/impl/codegen/call.h b/include/grpc++/impl/codegen/call.h index 4c2e550473..21b1f0a423 100644 --- a/include/grpc++/impl/codegen/call.h +++ b/include/grpc++/impl/codegen/call.h @@ -558,10 +558,11 @@ class CallOpRecvInitialMetadata { class CallOpClientRecvStatus { public: - CallOpClientRecvStatus() : recv_status_(nullptr) {} + CallOpClientRecvStatus() : recv_status_(nullptr), error_string_(nullptr) {} void ClientRecvStatus(ClientContext* context, Status* status) { - metadata_map_ = &context->trailing_metadata_; + client_context_ = context; + metadata_map_ = &client_context_->trailing_metadata_; recv_status_ = status; error_message_ = g_core_codegen_interface->grpc_empty_slice(); } @@ -588,18 +589,21 @@ class CallOpClientRecvStatus { binary_error_details = grpc::string(iter->second.begin(), iter->second.length()); } - *recv_status_ = - Status(static_cast(status_code_), - grpc::string(GRPC_SLICE_START_PTR(error_message_), - GRPC_SLICE_END_PTR(error_message_)), - binary_error_details, - error_string_ != nullptr ? grpc::string(error_string_) : ""); + *recv_status_ = Status(static_cast(status_code_), + grpc::string(GRPC_SLICE_START_PTR(error_message_), + GRPC_SLICE_END_PTR(error_message_)), + binary_error_details); + client_context_->set_debug_error_string( + error_string_ != nullptr ? grpc::string(error_string_) : ""); g_core_codegen_interface->grpc_slice_unref(error_message_); - g_core_codegen_interface->gpr_free((void*)error_string_); + if (error_string_ != nullptr) { + g_core_codegen_interface->gpr_free((void*)error_string_); + } recv_status_ = nullptr; } private: + ClientContext* client_context_; MetadataMap* metadata_map_; Status* recv_status_; const char* error_string_; diff --git a/include/grpc++/impl/codegen/client_context.h b/include/grpc++/impl/codegen/client_context.h index 22b581cbc5..9fe5f4093e 100644 --- a/include/grpc++/impl/codegen/client_context.h +++ b/include/grpc++/impl/codegen/client_context.h @@ -348,6 +348,8 @@ class ClientContext { /// Applications never need to call this method. grpc_call* c_call() { return call_; } + grpc::string debug_error_string() const { return debug_error_string_; } + private: // Disallow copy and assign. ClientContext(const ClientContext&); @@ -374,6 +376,11 @@ class ClientContext { template friend class ::grpc::internal::BlockingUnaryCallImpl; + // Used by friend class CallOpClientRecvStatus + void set_debug_error_string(grpc::string debug_error_string) { + debug_error_string_ = debug_error_string; + } + grpc_call* call() const { return call_; } void set_call(grpc_call* call, const std::shared_ptr& channel); @@ -412,6 +419,8 @@ class ClientContext { grpc_compression_algorithm compression_algorithm_; bool initial_metadata_corked_; + + grpc::string debug_error_string_; }; } // namespace grpc diff --git a/include/grpc++/impl/codegen/status.h b/include/grpc++/impl/codegen/status.h index cdaf5e1706..6f013cf0ca 100644 --- a/include/grpc++/impl/codegen/status.h +++ b/include/grpc++/impl/codegen/status.h @@ -46,16 +46,6 @@ class Status { error_message_(error_message), binary_error_details_(error_details) {} - /// Construct an instance with \a code, \a error_message and - /// \a error_details. It is an error to construct an OK status with non-empty - /// \a error_message and/or \a error_details. - Status(StatusCode code, const grpc::string& error_message, - const grpc::string& error_details, const grpc::string& error_string) - : code_(code), - error_message_(error_message), - binary_error_details_(error_details), - error_string_(error_string) {} - // Pre-defined special status objects. /// An OK pre-defined instance. static const Status& OK; @@ -69,8 +59,6 @@ class Status { /// Return the (binary) error details. // Usually it contains a serialized google.rpc.Status proto. grpc::string error_details() const { return binary_error_details_; } - /// Return the full fidelity error string, which includes all child errors. - grpc::string error_string() const { return error_string_; } /// Is the status OK? bool ok() const { return code_ == StatusCode::OK; } @@ -84,7 +72,6 @@ class Status { StatusCode code_; grpc::string error_message_; grpc::string binary_error_details_; - grpc::string error_string_; }; } // namespace grpc -- cgit v1.2.3