From 460898f11c464d66157ce539a22d71c896500444 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Fri, 23 Apr 2021 16:31:54 -0700 Subject: [PATCH] Migrated from grpc_error_string to grpc_error_std_string (#26068) * Added grpc_error_std_string * Migrated to grpc_error_std_string --- .../filters/client_channel/client_channel.cc | 51 +++++---- .../filters/client_channel/dynamic_filters.cc | 5 +- .../health/health_check_client.cc | 11 +- .../client_channel/lb_policy/grpclb/grpclb.cc | 2 +- .../client_channel/lb_policy/xds/cds.cc | 2 +- .../lb_policy/xds/xds_cluster_resolver.cc | 6 +- .../resolver/dns/c_ares/dns_resolver_ares.cc | 6 +- .../dns/c_ares/grpc_ares_ev_driver_windows.cc | 6 +- .../resolver/dns/c_ares/grpc_ares_wrapper.cc | 6 +- .../resolver/dns/native/dns_resolver.cc | 2 +- .../google_c2p/google_c2p_resolver.cc | 4 +- .../resolver/xds/xds_resolver.cc | 4 +- .../filters/client_channel/retry_filter.cc | 17 +-- .../service_config_channel_arg_filter.cc | 3 +- .../ext/filters/client_channel/subchannel.cc | 8 +- .../fault_injection/fault_injection_filter.cc | 2 +- .../transport/chttp2/server/chttp2_server.cc | 13 +-- .../chttp2/server/insecure/server_chttp2.cc | 3 +- .../server/insecure/server_chttp2_posix.cc | 2 +- .../server/secure/server_secure_chttp2.cc | 3 +- .../chttp2/transport/chttp2_transport.cc | 12 +-- .../ext/transport/chttp2/transport/parsing.cc | 3 +- .../ext/transport/inproc/inproc_transport.cc | 7 +- src/core/ext/xds/xds_api.cc | 5 +- src/core/ext/xds/xds_client.cc | 19 ++-- src/core/ext/xds/xds_server_config_fetcher.cc | 10 +- src/core/lib/channel/handshaker.cc | 4 +- .../lib/http/httpcli_security_connector.cc | 5 +- src/core/lib/iomgr/call_combiner.cc | 6 +- src/core/lib/iomgr/call_combiner.h | 3 +- src/core/lib/iomgr/endpoint_cfstream.cc | 6 +- src/core/lib/iomgr/error.cc | 4 + src/core/lib/iomgr/error.h | 2 + src/core/lib/iomgr/lockfree_event.cc | 2 +- src/core/lib/iomgr/parse_address.cc | 4 +- src/core/lib/iomgr/tcp_client_custom.cc | 3 +- src/core/lib/iomgr/tcp_client_posix.cc | 6 +- src/core/lib/iomgr/tcp_custom.cc | 18 ++-- src/core/lib/iomgr/tcp_posix.cc | 21 ++-- src/core/lib/iomgr/tcp_server_custom.cc | 5 +- src/core/lib/iomgr/tcp_server_posix.cc | 4 +- src/core/lib/iomgr/tcp_server_windows.cc | 4 +- .../security/authorization/rbac_translator.cc | 2 +- .../external/external_account_credentials.cc | 4 +- .../google_default_credentials.cc | 2 +- .../security/credentials/jwt/jwt_verifier.cc | 3 +- .../credentials/oauth2/oauth2_credentials.cc | 8 +- .../tls/grpc_tls_certificate_provider.cc | 9 +- .../tls/tls_security_connector.cc | 8 +- .../security/transport/security_handshaker.cc | 5 +- .../security/transport/server_auth_filter.cc | 2 +- src/core/lib/surface/call.cc | 2 +- src/core/lib/surface/channel.cc | 2 +- src/core/lib/surface/completion_queue.cc | 42 ++++---- src/core/lib/transport/error_utils.cc | 2 +- src/core/lib/transport/transport_op_string.cc | 10 +- .../alts/handshaker/alts_handshaker_client.cc | 2 +- .../alts/handshaker/alts_tsi_handshaker.cc | 2 +- src/cpp/client/secure_credentials.cc | 2 +- src/cpp/common/validate_service_config.cc | 2 +- test/core/channel/channelz_test.cc | 22 ++-- .../resolvers/dns_resolver_cooldown_test.cc | 3 +- .../client_channel/service_config_test.cc | 100 +++++++++--------- test/core/end2end/bad_server_response_test.cc | 3 +- .../end2end/fixtures/http_proxy_fixture.cc | 4 +- test/core/http/httpcli_test.cc | 2 +- test/core/http/httpscli_test.cc | 2 +- test/core/iomgr/error_test.cc | 2 +- .../ios/CFStreamTests/CFStreamClientTests.mm | 3 +- test/core/iomgr/tcp_server_posix_test.cc | 2 +- test/core/json/json_test.cc | 4 +- test/core/security/credentials_test.cc | 4 +- test/core/security/json_token_test.cc | 3 +- test/core/security/jwt_verifier_test.cc | 15 ++- test/core/security/oauth2_utils.cc | 3 +- .../print_google_default_creds_token.cc | 3 +- .../transport/chttp2/settings_timeout_test.cc | 5 +- test/core/util/port_server_client.cc | 5 +- ...tcher_certificate_provider_factory_test.cc | 32 +++--- ...sh_ca_certificate_provider_factory_test.cc | 32 +++--- test/core/xds/xds_bootstrap_test.cc | 80 +++++++------- .../core/xds/xds_certificate_provider_test.cc | 56 +++++----- ...channel_with_active_connect_stress_test.cc | 2 +- test/cpp/end2end/xds_end2end_test.cc | 4 +- test/cpp/naming/resolver_component_test.cc | 5 +- test/cpp/util/channel_trace_proto_helper.cc | 2 +- 86 files changed, 418 insertions(+), 398 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 7520fd777c8..3bbec5eaadc 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -1247,21 +1247,19 @@ void ClientChannel::OnResolverResultChangedLocked(Resolver::Result result) { trace_strings.push_back("Address list became non-empty"); } previous_resolution_contained_addresses_ = !result.addresses.empty(); - // The result of grpc_error_string() is owned by the error itself. - // We're storing that string in trace_strings, so we need to make sure - // that the error lives until we're done with the string. - grpc_error_handle service_config_error = - GRPC_ERROR_REF(result.service_config_error); - if (service_config_error != GRPC_ERROR_NONE) { - trace_strings.push_back(grpc_error_string(service_config_error)); + std::string service_config_error_string_storage; + if (result.service_config_error != GRPC_ERROR_NONE) { + service_config_error_string_storage = + grpc_error_std_string(result.service_config_error); + trace_strings.push_back(service_config_error_string_storage.c_str()); } // Choose the service config. RefCountedPtr service_config; RefCountedPtr config_selector; - if (service_config_error != GRPC_ERROR_NONE) { + if (result.service_config_error != GRPC_ERROR_NONE) { if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { gpr_log(GPR_INFO, "chand=%p: resolver returned service config error: %s", - this, grpc_error_string(service_config_error)); + this, grpc_error_std_string(result.service_config_error).c_str()); } // If the service config was invalid, then fallback to the // previously returned service config. @@ -1278,7 +1276,7 @@ void ClientChannel::OnResolverResultChangedLocked(Resolver::Result result) { // We received an invalid service config and we don't have a // previous service config to fall back to. Put the channel into // TRANSIENT_FAILURE. - OnResolverErrorLocked(GRPC_ERROR_REF(service_config_error)); + OnResolverErrorLocked(GRPC_ERROR_REF(result.service_config_error)); trace_strings.push_back("no valid service config"); } } else if (result.service_config == nullptr) { @@ -1343,7 +1341,6 @@ void ClientChannel::OnResolverResultChangedLocked(Resolver::Result result) { grpc_slice_from_cpp_string(message)); } } - GRPC_ERROR_UNREF(service_config_error); } void ClientChannel::OnResolverErrorLocked(grpc_error_handle error) { @@ -1353,7 +1350,7 @@ void ClientChannel::OnResolverErrorLocked(grpc_error_handle error) { } if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { gpr_log(GPR_INFO, "chand=%p: resolver transient failure: %s", this, - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); } // If we already have an LB policy from a previous resolution // result, then we continue to let it set the connectivity state. @@ -1731,7 +1728,7 @@ void ClientChannel::StartTransportOpLocked(grpc_transport_op* op) { if (op->disconnect_with_error != GRPC_ERROR_NONE) { if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) { gpr_log(GPR_INFO, "chand=%p: disconnect_with_error: %s", this, - grpc_error_string(op->disconnect_with_error)); + grpc_error_std_string(op->disconnect_with_error).c_str()); } DestroyResolverAndLbPolicyLocked(); intptr_t value; @@ -1930,7 +1927,8 @@ void ClientChannel::CallData::StartTransportStreamOpBatch( if (GPR_UNLIKELY(calld->cancel_error_ != GRPC_ERROR_NONE)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) { gpr_log(GPR_INFO, "chand=%p calld=%p: failing batch with error: %s", - chand, calld, grpc_error_string(calld->cancel_error_)); + chand, calld, + grpc_error_std_string(calld->cancel_error_).c_str()); } // Note: This will release the call combiner. grpc_transport_stream_op_batch_finish_with_failure( @@ -1949,7 +1947,7 @@ void ClientChannel::CallData::StartTransportStreamOpBatch( GRPC_ERROR_REF(batch->payload->cancel_stream.cancel_error); if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) { gpr_log(GPR_INFO, "chand=%p calld=%p: recording cancel_error=%s", chand, - calld, grpc_error_string(calld->cancel_error_)); + calld, grpc_error_std_string(calld->cancel_error_).c_str()); } // If we do not have a dynamic call (i.e., name resolution has not // yet completed), fail all pending batches. Otherwise, send the @@ -2065,7 +2063,8 @@ void ClientChannel::CallData::PendingBatchesFail( } gpr_log(GPR_INFO, "chand=%p calld=%p: failing %" PRIuPTR " pending batches: %s", - elem->channel_data, this, num_batches, grpc_error_string(error)); + elem->channel_data, this, num_batches, + grpc_error_std_string(error).c_str()); } CallCombinerClosureList closures; for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) { @@ -2157,7 +2156,7 @@ class ClientChannel::CallData::ResolverQueuedCallCanceller { gpr_log(GPR_INFO, "chand=%p calld=%p: cancelling resolver queued pick: " "error=%s self=%p calld->resolver_pick_canceller=%p", - chand, calld, grpc_error_string(error), self, + chand, calld, grpc_error_std_string(error).c_str(), self, calld->resolver_call_canceller_); } if (calld->resolver_call_canceller_ == self && error != GRPC_ERROR_NONE) { @@ -2307,7 +2306,7 @@ void ClientChannel::CallData::ResolutionDone(void* arg, if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { gpr_log(GPR_INFO, "chand=%p calld=%p: error applying config to call: error=%s", - chand, calld, grpc_error_string(error)); + chand, calld, grpc_error_std_string(error).c_str()); } calld->PendingBatchesFail(elem, GRPC_ERROR_REF(error), YieldCallCombiner); return; @@ -2416,7 +2415,7 @@ void ClientChannel::CallData::CreateDynamicCall(grpc_call_element* elem) { if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { gpr_log(GPR_INFO, "chand=%p calld=%p: failed to create dynamic call: error=%s", - chand, this, grpc_error_string(error)); + chand, this, grpc_error_std_string(error).c_str()); } PendingBatchesFail(elem, error, YieldCallCombiner); return; @@ -2617,7 +2616,7 @@ void ClientChannel::LoadBalancedCall::PendingBatchesFail( } gpr_log(GPR_INFO, "chand=%p lb_call=%p: failing %" PRIuPTR " pending batches: %s", - chand_, this, num_batches, grpc_error_string(error)); + chand_, this, num_batches, grpc_error_std_string(error).c_str()); } CallCombinerClosureList closures; for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) { @@ -2689,7 +2688,7 @@ void ClientChannel::LoadBalancedCall::StartTransportStreamOpBatch( if (GPR_UNLIKELY(cancel_error_ != GRPC_ERROR_NONE)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) { gpr_log(GPR_INFO, "chand=%p lb_call=%p: failing batch with error: %s", - chand_, this, grpc_error_string(cancel_error_)); + chand_, this, grpc_error_std_string(cancel_error_).c_str()); } // Note: This will release the call combiner. grpc_transport_stream_op_batch_finish_with_failure( @@ -2707,7 +2706,7 @@ void ClientChannel::LoadBalancedCall::StartTransportStreamOpBatch( cancel_error_ = GRPC_ERROR_REF(batch->payload->cancel_stream.cancel_error); if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) { gpr_log(GPR_INFO, "chand=%p lb_call=%p: recording cancel_error=%s", - chand_, this, grpc_error_string(cancel_error_)); + chand_, this, grpc_error_std_string(cancel_error_).c_str()); } // If we do not have a subchannel call (i.e., a pick has not yet // been started), fail all pending batches. Otherwise, send the @@ -2830,7 +2829,7 @@ void ClientChannel::LoadBalancedCall::CreateSubchannelCall() { if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { gpr_log(GPR_INFO, "chand=%p lb_call=%p: create subchannel_call=%p: error=%s", chand_, - this, subchannel_call_.get(), grpc_error_string(error)); + this, subchannel_call_.get(), grpc_error_std_string(error).c_str()); } if (on_call_destruction_complete_ != nullptr) { subchannel_call_->SetAfterCallStackDestroy(on_call_destruction_complete_); @@ -2870,7 +2869,7 @@ class ClientChannel::LoadBalancedCall::LbQueuedCallCanceller { gpr_log(GPR_INFO, "chand=%p lb_call=%p: cancelling queued pick: " "error=%s self=%p calld->pick_canceller=%p", - chand, lb_call, grpc_error_string(error), self, + chand, lb_call, grpc_error_std_string(error).c_str(), self, lb_call->lb_call_canceller_); } if (lb_call->lb_call_canceller_ == self && error != GRPC_ERROR_NONE) { @@ -2926,7 +2925,7 @@ void ClientChannel::LoadBalancedCall::PickDone(void* arg, if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { gpr_log(GPR_INFO, "chand=%p lb_call=%p: failed to pick subchannel: error=%s", - self->chand_, self, grpc_error_string(error)); + self->chand_, self, grpc_error_std_string(error).c_str()); } self->PendingBatchesFail(GRPC_ERROR_REF(error), YieldCallCombiner); return; @@ -2989,7 +2988,7 @@ bool ClientChannel::LoadBalancedCall::PickSubchannelLocked( GPR_INFO, "chand=%p lb_call=%p: LB pick returned %s (subchannel=%p, error=%s)", chand_, this, PickResultTypeName(result.type), result.subchannel.get(), - grpc_error_string(result.error)); + grpc_error_std_string(result.error).c_str()); } switch (result.type) { case LoadBalancingPolicy::PickResult::PICK_FAILED: { diff --git a/src/core/ext/filters/client_channel/dynamic_filters.cc b/src/core/ext/filters/client_channel/dynamic_filters.cc index cd7edc46add..47c05a30644 100644 --- a/src/core/ext/filters/client_channel/dynamic_filters.cc +++ b/src/core/ext/filters/client_channel/dynamic_filters.cc @@ -53,8 +53,7 @@ DynamicFilters::Call::Call(Args args, grpc_error_handle* error) *error = grpc_call_stack_init(channel_stack_->channel_stack_, 1, Destroy, this, &call_args); if (GPR_UNLIKELY(*error != GRPC_ERROR_NONE)) { - const char* error_string = grpc_error_string(*error); - gpr_log(GPR_ERROR, "error: %s", error_string); + gpr_log(GPR_ERROR, "error: %s", grpc_error_std_string(*error).c_str()); return; } grpc_call_stack_set_pollset_or_pollset_set(call_stack, args.pollent); @@ -145,7 +144,7 @@ std::pair CreateChannelStack( channel_stack); if (error != GRPC_ERROR_NONE) { gpr_log(GPR_ERROR, "error initializing client internal stack: %s", - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); grpc_channel_stack_destroy(channel_stack); gpr_free(channel_stack); return {nullptr, error}; diff --git a/src/core/ext/filters/client_channel/health/health_check_client.cc b/src/core/ext/filters/client_channel/health/health_check_client.cc index 7119daf2818..adde23d36a8 100644 --- a/src/core/ext/filters/client_channel/health/health_check_client.cc +++ b/src/core/ext/filters/client_channel/health/health_check_client.cc @@ -301,7 +301,8 @@ void HealthCheckClient::CallState::StartCall() { gpr_log(GPR_ERROR, "HealthCheckClient %p CallState %p: error creating health " "checking call on subchannel (%s); will retry", - health_check_client_.get(), this, grpc_error_string(error)); + health_check_client_.get(), this, + grpc_error_std_string(error).c_str()); GRPC_ERROR_UNREF(error); CallEndedLocked(/*retry=*/true); return; @@ -465,10 +466,10 @@ void HealthCheckClient::CallState::DoneReadingRecvMessage( const bool healthy = DecodeResponse(&recv_message_buffer_, &error); const grpc_connectivity_state state = healthy ? GRPC_CHANNEL_READY : GRPC_CHANNEL_TRANSIENT_FAILURE; - const char* reason = error == GRPC_ERROR_NONE && !healthy - ? "backend unhealthy" - : grpc_error_string(error); - health_check_client_->SetHealthStatus(state, reason); + health_check_client_->SetHealthStatus( + state, error == GRPC_ERROR_NONE && !healthy + ? "backend unhealthy" + : grpc_error_std_string(error).c_str()); seen_response_.Store(true, MemoryOrder::RELEASE); grpc_slice_buffer_destroy_internal(&recv_message_buffer_); // Start another recv_message batch. diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index ee3fdc0514d..3a20467b368 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -1202,7 +1202,7 @@ void GrpcLb::BalancerCallState::OnBalancerStatusReceivedLocked( "[grpclb %p] lb_calld=%p: Status from LB server received. " "Status = %d, details = '%s', (lb_call: %p), error '%s'", grpclb_policy(), this, lb_call_status_, status_details, lb_call_, - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); gpr_free(status_details); } GRPC_ERROR_UNREF(error); diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc index 0739c0bdacd..bd6b7d0ac5e 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc @@ -545,7 +545,7 @@ void CdsLb::OnClusterChanged(const std::string& name, void CdsLb::OnError(const std::string& name, grpc_error_handle error) { gpr_log(GPR_ERROR, "[cdslb %p] xds error obtaining data for cluster %s: %s", - this, name.c_str(), grpc_error_string(error)); + this, name.c_str(), grpc_error_std_string(error).c_str()); // Go into TRANSIENT_FAILURE if we have not yet created the child // policy (i.e., we have not yet received data from xds). Otherwise, // we keep running with the data we had previously. diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc index d67149bc6f0..bcb8194561b 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc @@ -734,7 +734,7 @@ void XdsClusterResolverLb::OnError(size_t index, grpc_error_handle error) { gpr_log(GPR_ERROR, "[xds_cluster_resolver_lb %p] discovery mechanism %" PRIuPTR " xds watcher reported error: %s", - this, index, grpc_error_string(error)); + this, index, grpc_error_std_string(error).c_str()); GRPC_ERROR_UNREF(error); if (shutting_down_) return; if (!discovery_mechanisms_[index].first_update_received) { @@ -1012,7 +1012,7 @@ XdsClusterResolverLb::CreateChildPolicyConfigLocked() { "[xds_cluster_resolver_lb %p] error parsing generated child policy " "config -- " "will put channel in TRANSIENT_FAILURE: %s", - this, grpc_error_string(error)); + this, grpc_error_std_string(error).c_str()); error = grpc_error_set_int( grpc_error_add_child(GRPC_ERROR_CREATE_FROM_STATIC_STRING( "xds_cluster_resolver LB policy: error " @@ -1112,7 +1112,7 @@ class XdsClusterResolverLbFactory : public LoadBalancingPolicyFactory { gpr_log(GPR_ERROR, "cannot get or create XdsClient to instantiate " "xds_cluster_resolver LB policy: %s", - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); GRPC_ERROR_UNREF(error); return nullptr; } diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc index 6d6c0c7e2e9..57c54b91ad2 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -204,7 +204,7 @@ void AresDnsResolver::OnNextResolutionLocked(grpc_error_handle error) { GRPC_CARES_TRACE_LOG( "resolver:%p re-resolution timer fired. error: %s. shutdown_initiated_: " "%d", - this, grpc_error_string(error), shutdown_initiated_); + this, grpc_error_std_string(error).c_str(), shutdown_initiated_); have_next_resolution_timer_ = false; if (error == GRPC_ERROR_NONE && !shutdown_initiated_) { if (!resolving_) { @@ -354,7 +354,7 @@ void AresDnsResolver::OnResolvedLocked(grpc_error_handle error) { backoff_.Reset(); } else { GRPC_CARES_TRACE_LOG("resolver:%p dns resolution failed: %s", this, - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); std::string error_message = absl::StrCat("DNS resolution failed for service: ", name_to_resolve_); result_handler_->ReturnError(grpc_error_set_int( @@ -365,7 +365,7 @@ void AresDnsResolver::OnResolvedLocked(grpc_error_handle error) { grpc_millis next_try = backoff_.NextAttemptTime(); grpc_millis timeout = next_try - ExecCtx::Get()->Now(); GRPC_CARES_TRACE_LOG("resolver:%p dns resolution failed (will retry): %s", - this, grpc_error_string(error)); + this, grpc_error_std_string(error).c_str()); GPR_ASSERT(!have_next_resolution_timer_); have_next_resolution_timer_ = true; // TODO(roth): We currently deal with this ref manually. Once the diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc index 19240153685..459b47335fa 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc @@ -436,7 +436,7 @@ class GrpcPolledFdWindows { "fd:%s InnerOnTcpConnectLocked error:|%s| " "pending_register_for_readable:%d" " pending_register_for_writeable:%d", - GetName(), grpc_error_string(error), + GetName(), grpc_error_std_string(error).c_str(), pending_continue_register_for_on_readable_locked_, pending_continue_register_for_on_writeable_locked_); GPR_ASSERT(!connect_done_); @@ -603,7 +603,7 @@ class GrpcPolledFdWindows { "fd:|%s| OnIocpReadableInner winsocket_->read_info.wsa_error " "code:|%d| msg:|%s|", GetName(), winsocket_->read_info.wsa_error, - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); } } } @@ -640,7 +640,7 @@ class GrpcPolledFdWindows { "fd:|%s| OnIocpWriteableInner. winsocket_->write_info.wsa_error " "code:|%d| msg:|%s|", GetName(), winsocket_->write_info.wsa_error, - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); } } GPR_ASSERT(tcp_write_state_ == WRITE_PENDING); diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc index 66d47e36a62..4637064b292 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc @@ -273,7 +273,8 @@ static void on_timeout_locked(grpc_ares_ev_driver* driver, GRPC_CARES_TRACE_LOG( "request:%p ev_driver=%p on_timeout_locked. driver->shutting_down=%d. " "err=%s", - driver->request, driver, driver->shutting_down, grpc_error_string(error)); + driver->request, driver, driver->shutting_down, + grpc_error_std_string(error).c_str()); if (!driver->shutting_down && error == GRPC_ERROR_NONE) { grpc_ares_ev_driver_shutdown_locked(driver); } @@ -315,7 +316,8 @@ static void on_ares_backup_poll_alarm_locked(grpc_ares_ev_driver* driver, "request:%p ev_driver=%p on_ares_backup_poll_alarm_locked. " "driver->shutting_down=%d. " "err=%s", - driver->request, driver, driver->shutting_down, grpc_error_string(error)); + driver->request, driver, driver->shutting_down, + grpc_error_std_string(error).c_str()); if (!driver->shutting_down && error == GRPC_ERROR_NONE) { fd_node* fdn = driver->fds; while (fdn != nullptr) { diff --git a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc index e8195eb1814..cc53febe9ec 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc @@ -194,7 +194,7 @@ void NativeDnsResolver::OnResolvedLocked(grpc_error_handle error) { backoff_.Reset(); } else { gpr_log(GPR_INFO, "dns resolution failed (will retry): %s", - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); // Return transient error. std::string error_message = absl::StrCat("DNS resolution failed for service: ", name_to_resolve_); diff --git a/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc b/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc index 07865f6d862..208ec67015e 100644 --- a/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc @@ -185,7 +185,7 @@ void GoogleCloud2ProdResolver::ZoneQuery::OnDone( grpc_error_handle error) { if (error != GRPC_ERROR_NONE) { gpr_log(GPR_ERROR, "error fetching zone from metadata server: %s", - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); } std::string zone; if (error == GRPC_ERROR_NONE && response->status == 200) { @@ -218,7 +218,7 @@ void GoogleCloud2ProdResolver::IPv6Query::OnDone( grpc_error_handle error) { if (error != GRPC_ERROR_NONE) { gpr_log(GPR_ERROR, "error fetching IPv6 address from metadata server: %s", - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); } resolver->IPv6QueryDone(error == GRPC_ERROR_NONE && response->status == 200); GRPC_ERROR_UNREF(error); diff --git a/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc b/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc index 2df770bf60e..3231ca27e63 100644 --- a/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc @@ -723,7 +723,7 @@ void XdsResolver::StartLocked() { gpr_log(GPR_ERROR, "Failed to create xds client -- channel will remain in " "TRANSIENT_FAILURE: %s", - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); result_handler_->ReturnError(error); return; } @@ -822,7 +822,7 @@ void XdsResolver::OnRouteConfigUpdate(XdsApi::RdsUpdate rds_update) { void XdsResolver::OnError(grpc_error_handle error) { gpr_log(GPR_ERROR, "[xds_resolver %p] received error from XdsClient: %s", - this, grpc_error_string(error)); + this, grpc_error_std_string(error).c_str()); Result result; result.args = grpc_channel_args_copy(args_); result.service_config_error = error; diff --git a/src/core/ext/filters/client_channel/retry_filter.cc b/src/core/ext/filters/client_channel/retry_filter.cc index 02774f4f17c..a03d2da10ed 100644 --- a/src/core/ext/filters/client_channel/retry_filter.cc +++ b/src/core/ext/filters/client_channel/retry_filter.cc @@ -604,7 +604,8 @@ class RetryFilter::CallData::Canceller { gpr_log(GPR_INFO, "calld=%p: cancelling retry timer: error=%s self=%p " "calld->canceller_=%p", - calld, grpc_error_string(error), self, calld->canceller_); + calld, grpc_error_std_string(error).c_str(), self, + calld->canceller_); } if (calld->canceller_ == self && error != GRPC_ERROR_NONE) { calld->canceller_ = nullptr; // Checked by OnRetryTimer(). @@ -1107,7 +1108,7 @@ void RetryFilter::CallData::CallAttempt::BatchData::RecvInitialMetadataReady( if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) { gpr_log(GPR_INFO, "chand=%p calld=%p: got recv_initial_metadata_ready, error=%s", - calld->chand_, calld, grpc_error_string(error)); + calld->chand_, calld, grpc_error_std_string(error).c_str()); } call_attempt->completed_recv_initial_metadata_ = true; // If a retry was already dispatched, then we're not going to use the @@ -1194,7 +1195,7 @@ void RetryFilter::CallData::CallAttempt::BatchData::RecvMessageReady( CallData* calld = call_attempt->calld_; if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) { gpr_log(GPR_INFO, "chand=%p calld=%p: got recv_message_ready, error=%s", - calld->chand_, calld, grpc_error_string(error)); + calld->chand_, calld, grpc_error_std_string(error).c_str()); } ++call_attempt->completed_recv_message_count_; // If a retry was already dispatched, then we're not going to use the @@ -1383,7 +1384,7 @@ void RetryFilter::CallData::CallAttempt::BatchData::RecvTrailingMetadataReady( if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) { gpr_log(GPR_INFO, "chand=%p calld=%p: got recv_trailing_metadata_ready, error=%s", - calld->chand_, calld, grpc_error_string(error)); + calld->chand_, calld, grpc_error_std_string(error).c_str()); } call_attempt->completed_recv_trailing_metadata_ = true; // Get the call's status and check for server pushback metadata. @@ -1491,7 +1492,7 @@ void RetryFilter::CallData::CallAttempt::BatchData::OnComplete( CallData* calld = call_attempt->calld_; if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) { gpr_log(GPR_INFO, "chand=%p calld=%p: got on_complete, error=%s, batch=%s", - calld->chand_, calld, grpc_error_string(error), + calld->chand_, calld, grpc_error_std_string(error).c_str(), grpc_transport_stream_op_batch_string(&batch_data->batch_).c_str()); } // Update bookkeeping in call_attempt. @@ -1580,7 +1581,7 @@ void RetryFilter::CallData::CallAttempt::BatchData:: retry_md, GRPC_BATCH_GRPC_PREVIOUS_RPC_ATTEMPTS); if (GPR_UNLIKELY(error != GRPC_ERROR_NONE)) { gpr_log(GPR_ERROR, "error adding retry metadata: %s", - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); GPR_ASSERT(false); } } @@ -1780,7 +1781,7 @@ void RetryFilter::CallData::StartTransportStreamOpBatch( grpc_error_handle cancel_error = batch->payload->cancel_stream.cancel_error; if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) { gpr_log(GPR_INFO, "chand=%p calld=%p: cancelled from surface: %s", chand_, - this, grpc_error_string(cancel_error)); + this, grpc_error_std_string(cancel_error).c_str()); } // If we have a current call attempt, commit the call, then send // the cancellation down to that attempt. When the call fails, it @@ -2072,7 +2073,7 @@ void RetryFilter::CallData::PendingBatchesFail(grpc_error_handle error) { } gpr_log(GPR_INFO, "chand=%p calld=%p: failing %" PRIuPTR " pending batches: %s", - chand_, this, num_batches, grpc_error_string(error)); + chand_, this, num_batches, grpc_error_std_string(error).c_str()); } CallCombinerClosureList closures; for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) { diff --git a/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc b/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc index 39a34630468..5763e17d8fb 100644 --- a/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +++ b/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc @@ -42,7 +42,8 @@ class ServiceConfigChannelArgChannelData { if (service_config_error == GRPC_ERROR_NONE) { service_config_ = std::move(service_config); } else { - gpr_log(GPR_ERROR, "%s", grpc_error_string(service_config_error)); + gpr_log(GPR_ERROR, "%s", + grpc_error_std_string(service_config_error).c_str()); } GRPC_ERROR_UNREF(service_config_error); } diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index e6cde203fd0..014bd73e0ec 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -156,8 +156,7 @@ SubchannelCall::SubchannelCall(Args args, grpc_error_handle* error) *error = grpc_call_stack_init(connected_subchannel_->channel_stack(), 1, SubchannelCall::Destroy, this, &call_args); if (GPR_UNLIKELY(*error != GRPC_ERROR_NONE)) { - const char* error_string = grpc_error_string(*error); - gpr_log(GPR_ERROR, "error: %s", error_string); + gpr_log(GPR_ERROR, "error: %s", grpc_error_std_string(*error).c_str()); return; } grpc_call_stack_set_pollset_or_pollset_set(callstk, args.pollent); @@ -1010,7 +1009,8 @@ void Subchannel::OnConnectingFinished(void* arg, grpc_error_handle error) { c->PublishTransportLocked()) { // Do nothing, transport was published. } else if (!c->disconnected_) { - gpr_log(GPR_INFO, "Connect failed: %s", grpc_error_string(error)); + gpr_log(GPR_INFO, "Connect failed: %s", + grpc_error_std_string(error).c_str()); c->SetConnectivityStateLocked(GRPC_CHANNEL_TRANSIENT_FAILURE, grpc_error_to_absl_status(error)); } @@ -1047,7 +1047,7 @@ bool Subchannel::PublishTransportLocked() { if (error != GRPC_ERROR_NONE) { grpc_transport_destroy(connecting_result_.transport); gpr_log(GPR_ERROR, "error initializing subchannel stack: %s", - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); GRPC_ERROR_UNREF(error); return false; } diff --git a/src/core/ext/filters/fault_injection/fault_injection_filter.cc b/src/core/ext/filters/fault_injection/fault_injection_filter.cc index d0afb63398a..5f8d7794414 100644 --- a/src/core/ext/filters/fault_injection/fault_injection_filter.cc +++ b/src/core/ext/filters/fault_injection/fault_injection_filter.cc @@ -214,7 +214,7 @@ class CallData::ResumeBatchCanceller { gpr_log(GPR_INFO, "chand=%p calld=%p: cancelling schdueled pick: " "error=%s self=%p calld->resume_batch_canceller_=%p", - chand, calld, grpc_error_string(error), self, + chand, calld, grpc_error_std_string(error).c_str(), self, calld->resume_batch_canceller_); } if (error != GRPC_ERROR_NONE && calld->resume_batch_canceller_ == self) { diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc index 009dafea545..5356e8c7d30 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.cc +++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc @@ -264,7 +264,7 @@ void Chttp2ServerListener::ConfigFetcherWatcher::UpdateConnectionManager( if (error != GRPC_ERROR_NONE) { GRPC_ERROR_UNREF(error); gpr_log(GPR_ERROR, "Error adding port to server: %s", - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); // TODO(yashykt): We wouldn't need to assert here if we bound to the // port earlier during AddPort. GPR_ASSERT(0); @@ -385,8 +385,8 @@ void Chttp2ServerListener::ActiveConnection::HandshakingState::OnHandshakeDone( { MutexLock connection_lock(&self->connection_->mu_); if (error != GRPC_ERROR_NONE || self->connection_->shutdown_) { - const char* error_str = grpc_error_string(error); - gpr_log(GPR_DEBUG, "Handshaking failed: %s", error_str); + std::string error_str = grpc_error_std_string(error); + gpr_log(GPR_DEBUG, "Handshaking failed: %s", error_str.c_str()); cleanup_connection = true; free_resource_quota = true; if (error == GRPC_ERROR_NONE && args->endpoint != nullptr) { @@ -455,7 +455,7 @@ void Chttp2ServerListener::ActiveConnection::HandshakingState::OnHandshakeDone( } else { // Failed to create channel from transport. Clean up. gpr_log(GPR_ERROR, "Failed to create channel: %s", - grpc_error_string(channel_init_err)); + grpc_error_std_string(channel_init_err).c_str()); GRPC_ERROR_UNREF(channel_init_err); grpc_transport_destroy(transport); grpc_slice_buffer_destroy_internal(args->read_buffer); @@ -735,7 +735,8 @@ void Chttp2ServerListener::OnAccept(void* arg, grpc_endpoint* tcp, grpc_error_handle error = GRPC_ERROR_NONE; args = self->args_modifier_(*args_result, &error); if (error != GRPC_ERROR_NONE) { - gpr_log(GPR_DEBUG, "Closing connection: %s", grpc_error_string(error)); + gpr_log(GPR_DEBUG, "Closing connection: %s", + grpc_error_std_string(error).c_str()); endpoint_cleanup(error); grpc_channel_args_destroy(args); return; @@ -877,7 +878,7 @@ grpc_error_handle Chttp2ServerAddPort(Server* server, const char* addr, resolved->naddrs - error_list.size(), resolved->naddrs); error = GRPC_ERROR_CREATE_REFERENCING_FROM_COPIED_STRING( msg.c_str(), error_list.data(), error_list.size()); - gpr_log(GPR_INFO, "WARNING: %s", grpc_error_string(error)); + gpr_log(GPR_INFO, "WARNING: %s", grpc_error_std_string(error).c_str()); GRPC_ERROR_UNREF(error); // we managed to bind some addresses: continue without error } diff --git a/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc b/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc index ee402cf678a..e00bc927cf1 100644 --- a/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +++ b/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc @@ -46,8 +46,7 @@ int grpc_server_add_insecure_http2_port(grpc_server* server, const char* addr) { grpc_channel_args_copy(server->core_server->channel_args()), ModifyArgsForConnection, &port_num); if (err != GRPC_ERROR_NONE) { - const char* msg = grpc_error_string(err); - gpr_log(GPR_ERROR, "%s", msg); + gpr_log(GPR_ERROR, "%s", grpc_error_std_string(err).c_str()); GRPC_ERROR_UNREF(err); } diff --git a/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc b/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc index 603be830bad..fd57939f21b 100644 --- a/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +++ b/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc @@ -60,7 +60,7 @@ void grpc_server_add_insecure_channel_from_fd(grpc_server* server, grpc_chttp2_transport_start_reading(transport, nullptr, nullptr, nullptr); } else { gpr_log(GPR_ERROR, "Failed to create channel: %s", - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); GRPC_ERROR_UNREF(error); grpc_transport_destroy(transport); } diff --git a/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc b/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc index b6c3d898e85..f0a0eed9193 100644 --- a/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +++ b/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc @@ -121,8 +121,7 @@ int grpc_server_add_secure_http2_port(grpc_server* server, const char* addr, done: sc.reset(DEBUG_LOCATION, "server"); if (err != GRPC_ERROR_NONE) { - const char* msg = grpc_error_string(err); - gpr_log(GPR_ERROR, "%s", msg); + gpr_log(GPR_ERROR, "%s", grpc_error_std_string(err).c_str()); GRPC_ERROR_UNREF(err); } diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 5486bfc5092..1ff64756c92 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -1104,7 +1104,7 @@ void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t, // received a GOAWAY with a non NO_ERROR code. if (goaway_error != GRPC_HTTP2_NO_ERROR) { gpr_log(GPR_INFO, "%s: Got goaway [%d] err=%s", t->peer_string.c_str(), - goaway_error, grpc_error_string(t->goaway_error)); + goaway_error, grpc_error_std_string(t->goaway_error).c_str()); } absl::Status status = grpc_error_to_absl_status(t->goaway_error); // When a client receives a GOAWAY with error code ENHANCE_YOUR_CALM and debug @@ -1220,7 +1220,6 @@ void grpc_chttp2_complete_closure_step(grpc_chttp2_transport* t, } closure->next_data.scratch -= CLOSURE_BARRIER_FIRST_REF_BIT; if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) { - const char* errstr = grpc_error_string(error); gpr_log( GPR_INFO, "complete_closure_step: t=%p %p refs=%d flags=0x%04x desc=%s err=%s " @@ -1230,7 +1229,8 @@ void grpc_chttp2_complete_closure_step(grpc_chttp2_transport* t, CLOSURE_BARRIER_FIRST_REF_BIT), static_cast(closure->next_data.scratch % CLOSURE_BARRIER_FIRST_REF_BIT), - desc, errstr, write_state_name(t->write_state)); + desc, grpc_error_std_string(error).c_str(), + write_state_name(t->write_state)); } if (error != GRPC_ERROR_NONE) { if (closure->error_data.error == GRPC_ERROR_NONE) { @@ -1752,7 +1752,7 @@ void grpc_chttp2_ack_ping(grpc_chttp2_transport* t, uint64_t id) { static void send_goaway(grpc_chttp2_transport* t, grpc_error_handle error) { // We want to log this irrespective of whether http tracing is enabled gpr_log(GPR_INFO, "%s: Sending goaway err=%s", t->peer_string.c_str(), - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); t->sent_goaway_state = GRPC_CHTTP2_GOAWAY_SEND_SCHEDULED; grpc_http2_error_code http_error; grpc_slice slice; @@ -2627,7 +2627,7 @@ static void start_bdp_ping_locked(void* tp, grpc_error_handle error) { grpc_chttp2_transport* t = static_cast(tp); if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) { gpr_log(GPR_INFO, "%s: Start BDP ping err=%s", t->peer_string.c_str(), - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); } if (error != GRPC_ERROR_NONE || t->closed_with_error != GRPC_ERROR_NONE) { return; @@ -2651,7 +2651,7 @@ static void finish_bdp_ping_locked(void* tp, grpc_error_handle error) { grpc_chttp2_transport* t = static_cast(tp); if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) { gpr_log(GPR_INFO, "%s: Complete BDP ping err=%s", t->peer_string.c_str(), - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); } if (error != GRPC_ERROR_NONE || t->closed_with_error != GRPC_ERROR_NONE) { GRPC_CHTTP2_UNREF_TRANSPORT(t, "bdp_ping"); diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc index e16d6c6c6a1..68e7c69c65f 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.cc +++ b/src/core/ext/transport/chttp2/transport/parsing.cc @@ -772,8 +772,7 @@ static grpc_error_handle parse_frame_slice(grpc_chttp2_transport* t, return err; } else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, &unused)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) { - const char* msg = grpc_error_string(err); - gpr_log(GPR_ERROR, "%s", msg); + gpr_log(GPR_ERROR, "%s", grpc_error_std_string(err).c_str()); } grpc_chttp2_parsing_become_skip_parser(t); if (s) { diff --git a/src/core/ext/transport/inproc/inproc_transport.cc b/src/core/ext/transport/inproc/inproc_transport.cc index d35cb542bbf..0c21db7f3af 100644 --- a/src/core/ext/transport/inproc/inproc_transport.cc +++ b/src/core/ext/transport/inproc/inproc_transport.cc @@ -889,7 +889,8 @@ done: bool cancel_stream_locked(inproc_stream* s, grpc_error_handle error) { bool ret = false; // was the cancel accepted - INPROC_LOG(GPR_INFO, "cancel_stream %p with %s", s, grpc_error_string(error)); + INPROC_LOG(GPR_INFO, "cancel_stream %p with %s", s, + grpc_error_std_string(error).c_str()); if (s->cancel_self_error == GRPC_ERROR_NONE) { ret = true; s->cancel_self_error = GRPC_ERROR_REF(error); @@ -1303,7 +1304,7 @@ grpc_channel* grpc_inproc_channel_create(grpc_server* server, if (error != GRPC_ERROR_NONE) { GPR_ASSERT(!channel); gpr_log(GPR_ERROR, "Failed to create client channel: %s", - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); intptr_t integer; grpc_status_code status = GRPC_STATUS_INTERNAL; if (grpc_error_get_int(error, GRPC_ERROR_INT_GRPC_STATUS, &integer)) { @@ -1318,7 +1319,7 @@ grpc_channel* grpc_inproc_channel_create(grpc_server* server, } else { GPR_ASSERT(!channel); gpr_log(GPR_ERROR, "Failed to create server channel: %s", - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); intptr_t integer; grpc_status_code status = GRPC_STATUS_INTERNAL; if (grpc_error_get_int(error, GRPC_ERROR_INT_GRPC_STATUS, &integer)) { diff --git a/src/core/ext/xds/xds_api.cc b/src/core/ext/xds/xds_api.cc index 4f311ca6a79..146aed5a8c6 100644 --- a/src/core/ext/xds/xds_api.cc +++ b/src/core/ext/xds/xds_api.cc @@ -1092,6 +1092,7 @@ grpc_slice XdsApi::CreateAdsRequest( request, StdStringToUpbString(nonce)); } // Set error_detail if it's a NACK. + std::string error_string_storage; if (error != GRPC_ERROR_NONE) { google_rpc_Status* error_detail = envoy_service_discovery_v3_DiscoveryRequest_mutable_error_detail( @@ -1102,8 +1103,8 @@ grpc_slice XdsApi::CreateAdsRequest( // generate them in the parsing code, and then use that here. google_rpc_Status_set_code(error_detail, GRPC_STATUS_INVALID_ARGUMENT); // Error description comes from the error that was passed in. - upb_strview error_description = - StdStringToUpbString(absl::string_view(grpc_error_string(error))); + error_string_storage = grpc_error_std_string(error); + upb_strview error_description = StdStringToUpbString(error_string_storage); google_rpc_Status_set_message(error_detail, error_description); GRPC_ERROR_UNREF(error); } diff --git a/src/core/ext/xds/xds_client.cc b/src/core/ext/xds/xds_client.cc index 88a7f4afe5f..4f536d0d41a 100644 --- a/src/core/ext/xds/xds_client.cc +++ b/src/core/ext/xds/xds_client.cc @@ -202,7 +202,7 @@ class XdsClient::ChannelState::AdsCallState watcher_error, GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE); if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) { gpr_log(GPR_INFO, "[xds_client %p] %s", ads_calld_->xds_client(), - grpc_error_string(watcher_error)); + grpc_error_std_string(watcher_error).c_str()); } if (type_url_ == XdsApi::kLdsTypeUrl) { ListenerState& state = ads_calld_->xds_client()->listener_map_[name_]; @@ -829,7 +829,7 @@ void XdsClient::ChannelState::AdsCallState::SendMessageLocked( "error=%s resources=%s", xds_client(), type_url.c_str(), xds_client()->resource_version_map_[type_url].c_str(), - state.nonce.c_str(), grpc_error_string(state.error), + state.nonce.c_str(), grpc_error_std_string(state.error).c_str(), absl::StrJoin(resource_names, " ").c_str()); } GRPC_ERROR_UNREF(state.error); @@ -1214,7 +1214,7 @@ bool XdsClient::ChannelState::AdsCallState::OnResponseReceivedLocked() { // Ignore unparsable response. gpr_log(GPR_ERROR, "[xds_client %p] Error parsing ADS response (%s) -- ignoring", - xds_client(), grpc_error_string(result.parse_error)); + xds_client(), grpc_error_std_string(result.parse_error).c_str()); GRPC_ERROR_UNREF(result.parse_error); } else { grpc_millis update_time = grpc_core::ExecCtx::Get()->Now(); @@ -1232,7 +1232,8 @@ bool XdsClient::ChannelState::AdsCallState::OnResponseReceivedLocked() { "[xds_client %p] ADS response invalid for resource type %s " "version %s, will NACK: nonce=%s error=%s", xds_client(), result.type_url.c_str(), result.version.c_str(), - state.nonce.c_str(), grpc_error_string(result.parse_error)); + state.nonce.c_str(), + grpc_error_std_string(result.parse_error).c_str()); SendMessageLocked(result.type_url); } else { seen_response_ = true; @@ -1296,7 +1297,7 @@ void XdsClient::ChannelState::AdsCallState::OnStatusReceivedLocked( "[xds_client %p] ADS call status received. Status = %d, details " "= '%s', (chand: %p, ads_calld: %p, call: %p), error '%s'", xds_client(), status_code_, status_details, chand(), this, call_, - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); gpr_free(status_details); } // Ignore status from a stale call. @@ -1659,7 +1660,7 @@ bool XdsClient::ChannelState::LrsCallState::OnResponseReceivedLocked() { if (parse_error != GRPC_ERROR_NONE) { gpr_log(GPR_ERROR, "[xds_client %p] LRS response parsing failed. error=%s", - xds_client(), grpc_error_string(parse_error)); + xds_client(), grpc_error_std_string(parse_error).c_str()); GRPC_ERROR_UNREF(parse_error); return; } @@ -1746,7 +1747,7 @@ void XdsClient::ChannelState::LrsCallState::OnStatusReceivedLocked( "[xds_client %p] LRS call status received. Status = %d, details " "= '%s', (chand: %p, calld: %p, call: %p), error '%s'", xds_client(), status_code_, status_details, chand(), this, call_, - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); gpr_free(status_details); } // Ignore status from a stale call. @@ -2255,7 +2256,7 @@ void XdsClient::UpdateResourceMetadataWithFailedParseResultLocked( grpc_millis update_time, const XdsApi::AdsParseResult& result) { // ADS update is rejected and the resource names in the failed update is // available. - absl::string_view details = grpc_error_string(result.parse_error); + std::string details = grpc_error_std_string(result.parse_error); for (auto& name : result.resource_names_failed) { XdsApi::ResourceMetadata* resource_metadata = nullptr; if (result.type_url == XdsApi::kLdsTypeUrl) { @@ -2284,7 +2285,7 @@ void XdsClient::UpdateResourceMetadataWithFailedParseResultLocked( } resource_metadata->client_status = XdsApi::ResourceMetadata::NACKED; resource_metadata->failed_version = result.version; - resource_metadata->failed_details = std::string(details); + resource_metadata->failed_details = details; resource_metadata->failed_update_time = update_time; } } diff --git a/src/core/ext/xds/xds_server_config_fetcher.cc b/src/core/ext/xds/xds_server_config_fetcher.cc index 6cdf3e5ebf1..f856704afbb 100644 --- a/src/core/ext/xds/xds_server_config_fetcher.cc +++ b/src/core/ext/xds/xds_server_config_fetcher.cc @@ -453,18 +453,20 @@ class XdsServerConfigFetcher : public grpc_server_config_fetcher { gpr_log(GPR_ERROR, "ListenerWatcher:%p XdsClient reports error: %s for %s; " "ignoring in favor of existing resource", - this, grpc_error_string(error), listening_address_.c_str()); + this, grpc_error_std_string(error).c_str(), + listening_address_.c_str()); } else { if (serving_status_notifier_.on_serving_status_change != nullptr) { serving_status_notifier_.on_serving_status_change( serving_status_notifier_.user_data, listening_address_.c_str(), - GRPC_STATUS_UNAVAILABLE, grpc_error_string(error)); + GRPC_STATUS_UNAVAILABLE, grpc_error_std_string(error).c_str()); } else { gpr_log( GPR_ERROR, "ListenerWatcher:%p error obtaining xDS Listener resource: %s; " "not serving on %s", - this, grpc_error_string(error), listening_address_.c_str()); + this, grpc_error_std_string(error).c_str(), + listening_address_.c_str()); } } GRPC_ERROR_UNREF(error); @@ -528,7 +530,7 @@ grpc_server_config_fetcher* grpc_server_config_fetcher_xds_create( grpc_core::XdsClient::GetOrCreate(args, &error); if (error != GRPC_ERROR_NONE) { gpr_log(GPR_ERROR, "Failed to create xds client: %s", - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); GRPC_ERROR_UNREF(error); return nullptr; } diff --git a/src/core/lib/channel/handshaker.cc b/src/core/lib/channel/handshaker.cc index e3b579a26e9..632d2864e31 100644 --- a/src/core/lib/channel/handshaker.cc +++ b/src/core/lib/channel/handshaker.cc @@ -88,7 +88,7 @@ bool HandshakeManager::CallNextHandshakerLocked(grpc_error_handle error) { gpr_log(GPR_INFO, "handshake_manager %p: error=%s shutdown=%d index=%" PRIuPTR ", args=%s", - this, grpc_error_string(error), is_shutdown_, index_, + this, grpc_error_std_string(error).c_str(), is_shutdown_, index_, HandshakerArgsString(&args_).c_str()); } GPR_ASSERT(index_ <= handshakers_.size()); @@ -121,7 +121,7 @@ bool HandshakeManager::CallNextHandshakerLocked(grpc_error_handle error) { gpr_log(GPR_INFO, "handshake_manager %p: handshaking complete -- scheduling " "on_handshake_done with error=%s", - this, grpc_error_string(error)); + this, grpc_error_std_string(error).c_str()); } // Cancel deadline timer, since we're invoking the on_handshake_done // callback now. diff --git a/src/core/lib/http/httpcli_security_connector.cc b/src/core/lib/http/httpcli_security_connector.cc index 75db9c789aa..e26f99b4bc5 100644 --- a/src/core/lib/http/httpcli_security_connector.cc +++ b/src/core/lib/http/httpcli_security_connector.cc @@ -169,9 +169,8 @@ static void on_handshake_done(void* arg, grpc_error_handle error) { auto* args = static_cast(arg); on_done_closure* c = static_cast(args->user_data); if (error != GRPC_ERROR_NONE) { - const char* msg = grpc_error_string(error); - gpr_log(GPR_ERROR, "Secure transport setup failed: %s", msg); - + gpr_log(GPR_ERROR, "Secure transport setup failed: %s", + grpc_error_std_string(error).c_str()); c->func(c->arg, nullptr); } else { grpc_channel_args_destroy(args->args); diff --git a/src/core/lib/iomgr/call_combiner.cc b/src/core/lib/iomgr/call_combiner.cc index 8e6a3405079..44ffb12722d 100644 --- a/src/core/lib/iomgr/call_combiner.cc +++ b/src/core/lib/iomgr/call_combiner.cc @@ -118,7 +118,8 @@ void CallCombiner::Start(grpc_closure* closure, grpc_error_handle error, gpr_log(GPR_INFO, "==> CallCombiner::Start() [%p] closure=%p [" DEBUG_FMT_STR "%s] error=%s", - this, closure DEBUG_FMT_ARGS, reason, grpc_error_string(error)); + this, closure DEBUG_FMT_ARGS, reason, + grpc_error_std_string(error).c_str()); } size_t prev_size = static_cast(gpr_atm_full_fetch_add(&size_, (gpr_atm)1)); @@ -177,7 +178,8 @@ void CallCombiner::Stop(DEBUG_ARGS const char* reason) { } if (GRPC_TRACE_FLAG_ENABLED(grpc_call_combiner_trace)) { gpr_log(GPR_INFO, " EXECUTING FROM QUEUE: closure=%p error=%s", - closure, grpc_error_string(closure->error_data.error)); + closure, + grpc_error_std_string(closure->error_data.error).c_str()); } ScheduleClosure(closure, closure->error_data.error); break; diff --git a/src/core/lib/iomgr/call_combiner.h b/src/core/lib/iomgr/call_combiner.h index 1d4118d8d82..e5429cca825 100644 --- a/src/core/lib/iomgr/call_combiner.h +++ b/src/core/lib/iomgr/call_combiner.h @@ -173,7 +173,8 @@ class CallCombinerClosureList { "CallCombinerClosureList executing closure while already " "holding call_combiner %p: closure=%p error=%s reason=%s", call_combiner, closures_[0].closure, - grpc_error_string(closures_[0].error), closures_[0].reason); + grpc_error_std_string(closures_[0].error).c_str(), + closures_[0].reason); } // This will release the call combiner. ExecCtx::Run(DEBUG_LOCATION, closures_[0].closure, closures_[0].error); diff --git a/src/core/lib/iomgr/endpoint_cfstream.cc b/src/core/lib/iomgr/endpoint_cfstream.cc index 8026ff5ee5c..2c3d22d880e 100644 --- a/src/core/lib/iomgr/endpoint_cfstream.cc +++ b/src/core/lib/iomgr/endpoint_cfstream.cc @@ -120,8 +120,7 @@ static void CallReadCb(CFStreamEndpoint* ep, grpc_error_handle error) { gpr_log(GPR_DEBUG, "CFStream endpoint:%p call_read_cb %p %p:%p", ep, ep->read_cb, ep->read_cb->cb, ep->read_cb->cb_arg); size_t i; - const char* str = grpc_error_string(error); - gpr_log(GPR_DEBUG, "read: error=%s", str); + gpr_log(GPR_DEBUG, "read: error=%s", grpc_error_std_string(error).c_str()); for (i = 0; i < ep->read_slices->count; i++) { char* dump = grpc_dump_slice(ep->read_slices->slices[i], @@ -141,8 +140,7 @@ static void CallWriteCb(CFStreamEndpoint* ep, grpc_error_handle error) { if (grpc_tcp_trace.enabled()) { gpr_log(GPR_DEBUG, "CFStream endpoint:%p call_write_cb %p %p:%p", ep, ep->write_cb, ep->write_cb->cb, ep->write_cb->cb_arg); - const char* str = grpc_error_string(error); - gpr_log(GPR_DEBUG, "write: error=%s", str); + gpr_log(GPR_DEBUG, "write: error=%s", grpc_error_std_string(error).c_str()); } grpc_closure* cb = ep->write_cb; ep->write_cb = nullptr; diff --git a/src/core/lib/iomgr/error.cc b/src/core/lib/iomgr/error.cc index e72fa9e08c2..191d65c7b20 100644 --- a/src/core/lib/iomgr/error.cc +++ b/src/core/lib/iomgr/error.cc @@ -777,6 +777,10 @@ const char* grpc_error_string(grpc_error_handle err) { return out; } +std::string grpc_error_std_string(grpc_error_handle error) { + return std::string(grpc_error_string(error)); +} + grpc_error_handle grpc_os_error(const char* file, int line, int err, const char* call_name) { return grpc_error_set_str( diff --git a/src/core/lib/iomgr/error.h b/src/core/lib/iomgr/error.h index c8ce38af7c2..85096c8312e 100644 --- a/src/core/lib/iomgr/error.h +++ b/src/core/lib/iomgr/error.h @@ -134,7 +134,9 @@ inline bool grpc_error_is_special(grpc_error_handle err) { void grpc_disable_error_creation(); void grpc_enable_error_creation(); +// DEPRECATED: Use grpc_error_std_string instead const char* grpc_error_string(grpc_error_handle error); +std::string grpc_error_std_string(grpc_error_handle error); /// Create an error - but use GRPC_ERROR_CREATE instead grpc_error_handle grpc_error_create(const char* file, int line, diff --git a/src/core/lib/iomgr/lockfree_event.cc b/src/core/lib/iomgr/lockfree_event.cc index 81a0812721a..fa21406c5bf 100644 --- a/src/core/lib/iomgr/lockfree_event.cc +++ b/src/core/lib/iomgr/lockfree_event.cc @@ -167,7 +167,7 @@ bool LockfreeEvent::SetShutdown(grpc_error_handle shutdown_error) { if (GRPC_TRACE_FLAG_ENABLED(grpc_polling_trace)) { gpr_log(GPR_DEBUG, "LockfreeEvent::SetShutdown: %p curr=%" PRIxPTR " err=%s", - &state_, curr, grpc_error_string(shutdown_error)); + &state_, curr, grpc_error_std_string(shutdown_error).c_str()); } switch (curr) { case kClosureReady: diff --git a/src/core/lib/iomgr/parse_address.cc b/src/core/lib/iomgr/parse_address.cc index 8531ed5d4c9..97d10c2cc6e 100644 --- a/src/core/lib/iomgr/parse_address.cc +++ b/src/core/lib/iomgr/parse_address.cc @@ -55,7 +55,7 @@ bool grpc_parse_unix(const grpc_core::URI& uri, grpc_error_handle error = grpc_core::UnixSockaddrPopulate(uri.path(), resolved_addr); if (error != GRPC_ERROR_NONE) { - gpr_log(GPR_ERROR, "%s", grpc_error_string(error)); + gpr_log(GPR_ERROR, "%s", grpc_error_std_string(error).c_str()); GRPC_ERROR_UNREF(error); return false; } @@ -72,7 +72,7 @@ bool grpc_parse_unix_abstract(const grpc_core::URI& uri, grpc_error_handle error = grpc_core::UnixAbstractSockaddrPopulate(uri.path(), resolved_addr); if (error != GRPC_ERROR_NONE) { - gpr_log(GPR_ERROR, "%s", grpc_error_string(error)); + gpr_log(GPR_ERROR, "%s", grpc_error_std_string(error).c_str()); GRPC_ERROR_UNREF(error); return false; } diff --git a/src/core/lib/iomgr/tcp_client_custom.cc b/src/core/lib/iomgr/tcp_client_custom.cc index a54bfd0e3b3..b38cd27c0d6 100644 --- a/src/core/lib/iomgr/tcp_client_custom.cc +++ b/src/core/lib/iomgr/tcp_client_custom.cc @@ -64,9 +64,8 @@ static void on_alarm(void* acp, grpc_error_handle error) { grpc_custom_socket* socket = static_cast(acp); grpc_custom_tcp_connect* connect = socket->connector; if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) { - const char* str = grpc_error_string(error); gpr_log(GPR_INFO, "CLIENT_CONNECT: %s: on_alarm: error=%s", - connect->addr_name.c_str(), str); + connect->addr_name.c_str(), grpc_error_std_string(error).c_str()); } if (error == GRPC_ERROR_NONE) { /* error == NONE implies that the timer ran out, and wasn't cancelled. If diff --git a/src/core/lib/iomgr/tcp_client_posix.cc b/src/core/lib/iomgr/tcp_client_posix.cc index e78a5ad399f..d7ca230b31a 100644 --- a/src/core/lib/iomgr/tcp_client_posix.cc +++ b/src/core/lib/iomgr/tcp_client_posix.cc @@ -104,9 +104,8 @@ static void tc_on_alarm(void* acp, grpc_error_handle error) { int done; async_connect* ac = static_cast(acp); if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) { - const char* str = grpc_error_string(error); gpr_log(GPR_INFO, "CLIENT_CONNECT: %s: on_alarm: error=%s", - ac->addr_str.c_str(), str); + ac->addr_str.c_str(), grpc_error_std_string(error).c_str()); } gpr_mu_lock(&ac->mu); if (ac->fd != nullptr) { @@ -140,9 +139,8 @@ static void on_writable(void* acp, grpc_error_handle error) { GRPC_ERROR_REF(error); if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) { - const char* str = grpc_error_string(error); gpr_log(GPR_INFO, "CLIENT_CONNECT: %s: on_writable: error=%s", - ac->addr_str.c_str(), str); + ac->addr_str.c_str(), grpc_error_std_string(error).c_str()); } gpr_mu_lock(&ac->mu); diff --git a/src/core/lib/iomgr/tcp_custom.cc b/src/core/lib/iomgr/tcp_custom.cc index a2db8d3bd75..5b199ae8267 100644 --- a/src/core/lib/iomgr/tcp_custom.cc +++ b/src/core/lib/iomgr/tcp_custom.cc @@ -128,9 +128,7 @@ static void call_read_cb(custom_tcp_endpoint* tcp, grpc_error_handle error) { gpr_log(GPR_INFO, "TCP:%p call_cb %p %p:%p", tcp->socket, cb, cb->cb, cb->cb_arg); size_t i; - const char* str = grpc_error_string(error); - gpr_log(GPR_INFO, "read: error=%s", str); - + gpr_log(GPR_INFO, "read: error=%s", grpc_error_std_string(error).c_str()); for (i = 0; i < tcp->read_slices->count; i++) { char* dump = grpc_dump_slice(tcp->read_slices->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII); @@ -175,7 +173,7 @@ static void tcp_read_allocation_done(void* tcpp, grpc_error_handle error) { custom_tcp_endpoint* tcp = static_cast(tcpp); if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) { gpr_log(GPR_INFO, "TCP:%p read_allocation_done: %s", tcp->socket, - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); } if (error == GRPC_ERROR_NONE) { /* Before calling read, we allocate a buffer with exactly one slice @@ -191,8 +189,8 @@ static void tcp_read_allocation_done(void* tcpp, grpc_error_handle error) { call_read_cb(tcp, GRPC_ERROR_REF(error)); } if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) { - const char* str = grpc_error_string(error); - gpr_log(GPR_INFO, "Initiating read on %p: error=%s", tcp->socket, str); + gpr_log(GPR_INFO, "Initiating read on %p: error=%s", tcp->socket, + grpc_error_std_string(error).c_str()); } } @@ -221,8 +219,8 @@ static void custom_write_callback(grpc_custom_socket* socket, grpc_closure* cb = tcp->write_cb; tcp->write_cb = nullptr; if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) { - const char* str = grpc_error_string(error); - gpr_log(GPR_INFO, "write complete on %p: error=%s", tcp->socket, str); + gpr_log(GPR_INFO, "write complete on %p: error=%s", tcp->socket, + grpc_error_std_string(error).c_str()); } TCP_UNREF(tcp, "write"); grpc_core::ExecCtx::Run(DEBUG_LOCATION, cb, error); @@ -291,8 +289,8 @@ static void endpoint_shutdown(grpc_endpoint* ep, grpc_error_handle why) { custom_tcp_endpoint* tcp = reinterpret_cast(ep); if (!tcp->shutting_down) { if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) { - const char* str = grpc_error_string(why); - gpr_log(GPR_INFO, "TCP %p shutdown why=%s", tcp->socket, str); + gpr_log(GPR_INFO, "TCP %p shutdown why=%s", tcp->socket, + grpc_error_std_string(why).c_str()); } tcp->shutting_down = true; // grpc_core::ExecCtx::Run(DEBUG_LOCATION,tcp->read_cb, diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index 8ac7a20e187..ab42baadff2 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -563,7 +563,8 @@ static void notify_on_write(grpc_tcp* tcp) { static void tcp_drop_uncovered_then_handle_write(void* arg, grpc_error_handle error) { if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) { - gpr_log(GPR_INFO, "TCP:%p got_write: %s", arg, grpc_error_string(error)); + gpr_log(GPR_INFO, "TCP:%p got_write: %s", arg, + grpc_error_std_string(error).c_str()); } drop_uncovered(static_cast(arg)); tcp_handle_write(arg, error); @@ -686,10 +687,8 @@ static void call_read_cb(grpc_tcp* tcp, grpc_error_handle error) { if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) { gpr_log(GPR_INFO, "TCP:%p call_cb %p %p:%p", tcp, cb, cb->cb, cb->cb_arg); size_t i; - const char* str = grpc_error_string(error); gpr_log(GPR_INFO, "READ %p (peer=%s) error=%s", tcp, - tcp->peer_string.c_str(), str); - + tcp->peer_string.c_str(), grpc_error_std_string(error).c_str()); if (gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) { for (i = 0; i < tcp->incoming_buffer->count; i++) { char* dump = grpc_dump_slice(tcp->incoming_buffer->slices[i], @@ -856,7 +855,7 @@ static void tcp_read_allocation_done(void* tcpp, grpc_error_handle error) { grpc_tcp* tcp = static_cast(tcpp); if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) { gpr_log(GPR_INFO, "TCP:%p read_allocation_done: %s", tcp, - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); } if (GPR_UNLIKELY(error != GRPC_ERROR_NONE)) { grpc_slice_buffer_reset_and_unref_internal(tcp->incoming_buffer); @@ -892,7 +891,8 @@ static void tcp_continue_read(grpc_tcp* tcp) { static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error_handle error) { grpc_tcp* tcp = static_cast(arg); if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) { - gpr_log(GPR_INFO, "TCP:%p got_read: %s", tcp, grpc_error_string(error)); + gpr_log(GPR_INFO, "TCP:%p got_read: %s", tcp, + grpc_error_std_string(error).c_str()); } if (GPR_UNLIKELY(error != GRPC_ERROR_NONE)) { @@ -1219,7 +1219,8 @@ static void tcp_handle_error(void* arg /* grpc_tcp */, grpc_error_handle error) { grpc_tcp* tcp = static_cast(arg); if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) { - gpr_log(GPR_INFO, "TCP:%p got_error: %s", tcp, grpc_error_string(error)); + gpr_log(GPR_INFO, "TCP:%p got_error: %s", tcp, + grpc_error_std_string(error).c_str()); } if (error != GRPC_ERROR_NONE || @@ -1553,8 +1554,7 @@ static void tcp_handle_write(void* arg /* grpc_tcp */, tcp->write_cb = nullptr; tcp->current_zerocopy_send = nullptr; if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) { - const char* str = grpc_error_string(error); - gpr_log(GPR_INFO, "write: %s", str); + gpr_log(GPR_INFO, "write: %s", grpc_error_std_string(error).c_str()); } // No need to take a ref on error since tcp_flush provides a ref. grpc_core::Closure::Run(DEBUG_LOCATION, cb, error); @@ -1622,8 +1622,7 @@ static void tcp_write(grpc_endpoint* ep, grpc_slice_buffer* buf, notify_on_write(tcp); } else { if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) { - const char* str = grpc_error_string(error); - gpr_log(GPR_INFO, "write: %s", str); + gpr_log(GPR_INFO, "write: %s", grpc_error_std_string(error).c_str()); } grpc_core::Closure::Run(DEBUG_LOCATION, cb, error); } diff --git a/src/core/lib/iomgr/tcp_server_custom.cc b/src/core/lib/iomgr/tcp_server_custom.cc index 15ea093a9ad..f29cf275445 100644 --- a/src/core/lib/iomgr/tcp_server_custom.cc +++ b/src/core/lib/iomgr/tcp_server_custom.cc @@ -256,7 +256,8 @@ static void custom_accept_callback(grpc_custom_socket* socket, grpc_tcp_listener* sp = socket->listener; if (error != GRPC_ERROR_NONE) { if (!sp->closed) { - gpr_log(GPR_ERROR, "Accept failed: %s", grpc_error_string(error)); + gpr_log(GPR_ERROR, "Accept failed: %s", + grpc_error_std_string(error).c_str()); } gpr_free(client); GRPC_ERROR_UNREF(error); @@ -392,7 +393,7 @@ static grpc_error_handle tcp_server_add_port(grpc_tcp_server* s, if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) { gpr_log(GPR_INFO, "SERVER %p add_port %s error=%s", s, grpc_sockaddr_to_string(addr, false).c_str(), - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); } family = grpc_sockaddr_get_family(addr); diff --git a/src/core/lib/iomgr/tcp_server_posix.cc b/src/core/lib/iomgr/tcp_server_posix.cc index 544d460250a..b7ba4681ebf 100644 --- a/src/core/lib/iomgr/tcp_server_posix.cc +++ b/src/core/lib/iomgr/tcp_server_posix.cc @@ -325,14 +325,14 @@ static grpc_error_handle add_wildcard_addrs_to_server(grpc_tcp_server* s, gpr_log(GPR_INFO, "Failed to add :: listener, " "the environment may not support IPv6: %s", - grpc_error_string(v6_err)); + grpc_error_std_string(v6_err).c_str()); GRPC_ERROR_UNREF(v6_err); } if (v4_err != GRPC_ERROR_NONE) { gpr_log(GPR_INFO, "Failed to add 0.0.0.0 listener, " "the environment may not support IPv4: %s", - grpc_error_string(v4_err)); + grpc_error_std_string(v4_err).c_str()); GRPC_ERROR_UNREF(v4_err); } return GRPC_ERROR_NONE; diff --git a/src/core/lib/iomgr/tcp_server_windows.cc b/src/core/lib/iomgr/tcp_server_windows.cc index 1957f2ac074..e314a4f7d86 100644 --- a/src/core/lib/iomgr/tcp_server_windows.cc +++ b/src/core/lib/iomgr/tcp_server_windows.cc @@ -318,8 +318,8 @@ static void on_accept(void* arg, grpc_error_handle error) { this is necessary in the read/write case, it's useless for the accept case. We only need to adjust the pending callback count */ if (error != GRPC_ERROR_NONE) { - const char* msg = grpc_error_string(error); - gpr_log(GPR_INFO, "Skipping on_accept due to error: %s", msg); + gpr_log(GPR_INFO, "Skipping on_accept due to error: %s", + grpc_error_std_string(error).c_str()); gpr_mu_unlock(&sp->server->mu); return; diff --git a/src/core/lib/security/authorization/rbac_translator.cc b/src/core/lib/security/authorization/rbac_translator.cc index 8bb5b53cad7..ea5599dde9a 100644 --- a/src/core/lib/security/authorization/rbac_translator.cc +++ b/src/core/lib/security/authorization/rbac_translator.cc @@ -302,7 +302,7 @@ absl::StatusOr GenerateRbacPolicies( if (error != GRPC_ERROR_NONE) { absl::Status status = absl::InvalidArgumentError( absl::StrCat("Failed to parse SDK authorization policy. Error: ", - grpc_error_string(error))); + grpc_error_std_string(error))); GRPC_ERROR_UNREF(error); return status; } diff --git a/src/core/lib/security/credentials/external/external_account_credentials.cc b/src/core/lib/security/credentials/external/external_account_credentials.cc index 67e46cc89ff..f5d9442e362 100644 --- a/src/core/lib/security/credentials/external/external_account_credentials.cc +++ b/src/core/lib/security/credentials/external/external_account_credentials.cc @@ -481,7 +481,7 @@ grpc_call_credentials* grpc_external_account_credentials_create( if (error != GRPC_ERROR_NONE) { gpr_log(GPR_ERROR, "External account credentials creation failed. Error: %s.", - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); GRPC_ERROR_UNREF(error); return nullptr; } @@ -492,7 +492,7 @@ grpc_call_credentials* grpc_external_account_credentials_create( if (error != GRPC_ERROR_NONE) { gpr_log(GPR_ERROR, "External account credentials creation failed. Error: %s.", - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); GRPC_ERROR_UNREF(error); return nullptr; } diff --git a/src/core/lib/security/credentials/google_default/google_default_credentials.cc b/src/core/lib/security/credentials/google_default/google_default_credentials.cc index 0dbf44f724a..0e1a2a10374 100644 --- a/src/core/lib/security/credentials/google_default/google_default_credentials.cc +++ b/src/core/lib/security/credentials/google_default/google_default_credentials.cc @@ -373,7 +373,7 @@ grpc_channel_credentials* grpc_google_default_credentials_create( GPR_ASSERT(result != nullptr); } else { gpr_log(GPR_ERROR, "Could not create google default credentials: %s", - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); } GRPC_ERROR_UNREF(error); return result; diff --git a/src/core/lib/security/credentials/jwt/jwt_verifier.cc b/src/core/lib/security/credentials/jwt/jwt_verifier.cc index 96fb16d30c3..8d43cf988f9 100644 --- a/src/core/lib/security/credentials/jwt/jwt_verifier.cc +++ b/src/core/lib/security/credentials/jwt/jwt_verifier.cc @@ -90,7 +90,8 @@ static Json parse_json_part_from_jwt(const char* str, size_t len) { grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(string, &error); if (error != GRPC_ERROR_NONE) { - gpr_log(GPR_ERROR, "JSON parse error: %s", grpc_error_string(error)); + gpr_log(GPR_ERROR, "JSON parse error: %s", + grpc_error_std_string(error).c_str()); GRPC_ERROR_UNREF(error); json = Json(); // JSON null } diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc index 34bb71cfdf2..50d20e64bbe 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc @@ -97,7 +97,8 @@ grpc_auth_refresh_token grpc_auth_refresh_token_create_from_string( grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_string, &error); if (error != GRPC_ERROR_NONE) { - gpr_log(GPR_ERROR, "JSON parsing failed: %s", grpc_error_string(error)); + gpr_log(GPR_ERROR, "JSON parsing failed: %s", + grpc_error_std_string(error).c_str()); GRPC_ERROR_UNREF(error); } return grpc_auth_refresh_token_create_from_json(json); @@ -168,7 +169,7 @@ grpc_oauth2_token_fetcher_credentials_parse_server_response( json = Json::Parse(null_terminated_body, &error); if (error != GRPC_ERROR_NONE) { gpr_log(GPR_ERROR, "Could not parse JSON from %s: %s", - null_terminated_body, grpc_error_string(error)); + null_terminated_body, grpc_error_std_string(error).c_str()); GRPC_ERROR_UNREF(error); status = GRPC_CREDENTIALS_ERROR; goto end; @@ -685,7 +686,8 @@ absl::StatusOr ValidateStsCredentialsOptions( } auto grpc_error_vec = GRPC_ERROR_CREATE_FROM_VECTOR( "Invalid STS Credentials Options", &error_list); - auto retval = absl::InvalidArgumentError(grpc_error_string(grpc_error_vec)); + auto retval = + absl::InvalidArgumentError(grpc_error_std_string(grpc_error_vec)); GRPC_ERROR_UNREF(grpc_error_vec); return retval; } diff --git a/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc b/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc index e860be51a8b..b4b6bf556c9 100644 --- a/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +++ b/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc @@ -261,7 +261,8 @@ FileWatcherCertificateProvider::ReadRootCertificatesFromFile( grpc_load_file(root_cert_full_path.c_str(), 0, &root_slice); if (root_error != GRPC_ERROR_NONE) { gpr_log(GPR_ERROR, "Reading file %s failed: %s", - root_cert_full_path.c_str(), grpc_error_string(root_error)); + root_cert_full_path.c_str(), + grpc_error_std_string(root_error).c_str()); GRPC_ERROR_UNREF(root_error); return absl::nullopt; } @@ -319,7 +320,8 @@ FileWatcherCertificateProvider::ReadIdentityKeyCertPairFromFiles( grpc_load_file(private_key_path.c_str(), 0, &key_slice.slice); if (key_error != GRPC_ERROR_NONE) { gpr_log(GPR_ERROR, "Reading file %s failed: %s. Start retrying...", - private_key_path.c_str(), grpc_error_string(key_error)); + private_key_path.c_str(), + grpc_error_std_string(key_error).c_str()); GRPC_ERROR_UNREF(key_error); continue; } @@ -327,7 +329,8 @@ FileWatcherCertificateProvider::ReadIdentityKeyCertPairFromFiles( grpc_load_file(identity_certificate_path.c_str(), 0, &cert_slice.slice); if (cert_error != GRPC_ERROR_NONE) { gpr_log(GPR_ERROR, "Reading file %s failed: %s. Start retrying...", - identity_certificate_path.c_str(), grpc_error_string(cert_error)); + identity_certificate_path.c_str(), + grpc_error_std_string(cert_error).c_str()); GRPC_ERROR_UNREF(cert_error); continue; } diff --git a/src/core/lib/security/security_connector/tls/tls_security_connector.cc b/src/core/lib/security/security_connector/tls/tls_security_connector.cc index 1625aa78bc7..ea6b42e07d6 100644 --- a/src/core/lib/security/security_connector/tls/tls_security_connector.cc +++ b/src/core/lib/security/security_connector/tls/tls_security_connector.cc @@ -363,12 +363,12 @@ void TlsChannelSecurityConnector::TlsChannelCertificateWatcher::OnError( if (root_cert_error != GRPC_ERROR_NONE) { gpr_log(GPR_ERROR, "TlsChannelCertificateWatcher getting root_cert_error: %s", - grpc_error_string(root_cert_error)); + grpc_error_std_string(root_cert_error).c_str()); } if (identity_cert_error != GRPC_ERROR_NONE) { gpr_log(GPR_ERROR, "TlsChannelCertificateWatcher getting identity_cert_error: %s", - grpc_error_string(identity_cert_error)); + grpc_error_std_string(identity_cert_error).c_str()); } GRPC_ERROR_UNREF(root_cert_error); GRPC_ERROR_UNREF(identity_cert_error); @@ -621,12 +621,12 @@ void TlsServerSecurityConnector::TlsServerCertificateWatcher::OnError( if (root_cert_error != GRPC_ERROR_NONE) { gpr_log(GPR_ERROR, "TlsServerCertificateWatcher getting root_cert_error: %s", - grpc_error_string(root_cert_error)); + grpc_error_std_string(root_cert_error).c_str()); } if (identity_cert_error != GRPC_ERROR_NONE) { gpr_log(GPR_ERROR, "TlsServerCertificateWatcher getting identity_cert_error: %s", - grpc_error_string(identity_cert_error)); + grpc_error_std_string(identity_cert_error).c_str()); } GRPC_ERROR_UNREF(root_cert_error); GRPC_ERROR_UNREF(identity_cert_error); diff --git a/src/core/lib/security/transport/security_handshaker.cc b/src/core/lib/security/transport/security_handshaker.cc index 7918c2842ef..6d05c97078b 100644 --- a/src/core/lib/security/transport/security_handshaker.cc +++ b/src/core/lib/security/transport/security_handshaker.cc @@ -180,9 +180,8 @@ void SecurityHandshaker::HandshakeFailedLocked(grpc_error_handle error) { // endpoint callback was invoked, we need to generate our own error. error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Handshaker shutdown"); } - const char* msg = grpc_error_string(error); - gpr_log(GPR_DEBUG, "Security handshake failed: %s", msg); - + gpr_log(GPR_DEBUG, "Security handshake failed: %s", + grpc_error_std_string(error).c_str()); if (!is_shutdown_) { tsi_handshaker_shutdown(handshaker_); // TODO(ctiller): It is currently necessary to shutdown endpoints diff --git a/src/core/lib/security/transport/server_auth_filter.cc b/src/core/lib/security/transport/server_auth_filter.cc index 7f644de8161..65a7e405569 100644 --- a/src/core/lib/security/transport/server_auth_filter.cc +++ b/src/core/lib/security/transport/server_auth_filter.cc @@ -310,7 +310,7 @@ static grpc_error_handle server_auth_init_channel_elem( grpc_error_handle error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( "No authorization context found. This might be a TRANSIENT failure due " "to certificates not having been loaded yet."); - gpr_log(GPR_DEBUG, "%s", grpc_error_string(error)); + gpr_log(GPR_DEBUG, "%s", grpc_error_std_string(error).c_str()); return error; } GPR_ASSERT(auth_context != nullptr); diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 3407c54672b..ac0854c2210 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -743,7 +743,7 @@ static void cancel_with_status(grpc_call* c, grpc_status_code status, static void set_final_status(grpc_call* call, grpc_error_handle error) { if (GRPC_TRACE_FLAG_ENABLED(grpc_call_error_trace)) { gpr_log(GPR_DEBUG, "set_final_status %s", call->is_client ? "CLI" : "SVR"); - gpr_log(GPR_DEBUG, "%s", grpc_error_string(error)); + gpr_log(GPR_DEBUG, "%s", grpc_error_std_string(error).c_str()); } if (call->is_client) { grpc_error_get_status(error, call->send_deadline, diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 11406d5d23c..d3552c874f3 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -75,7 +75,7 @@ grpc_channel* grpc_channel_create_with_builder( reinterpret_cast(&channel)); if (builder_error != GRPC_ERROR_NONE) { gpr_log(GPR_ERROR, "channel stack builder failed: %s", - grpc_error_string(builder_error)); + grpc_error_std_string(builder_error).c_str()); GPR_ASSERT(channel == nullptr); if (error != nullptr) { *error = builder_error; diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index 73bf2061727..2b889e0de5c 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -698,14 +698,15 @@ static void cq_end_op_for_next( if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace) || (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures) && error != GRPC_ERROR_NONE)) { - const char* errmsg = grpc_error_string(error); + std::string errmsg = grpc_error_std_string(error); GRPC_API_TRACE( "cq_end_op_for_next(cq=%p, tag=%p, error=%s, " "done=%p, done_arg=%p, storage=%p)", - 6, (cq, tag, errmsg, done, done_arg, storage)); + 6, (cq, tag, errmsg.c_str(), done, done_arg, storage)); if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures) && error != GRPC_ERROR_NONE) { - gpr_log(GPR_INFO, "Operation failed: tag=%p, error=%s", tag, errmsg); + gpr_log(GPR_INFO, "Operation failed: tag=%p, error=%s", tag, + errmsg.c_str()); } } cq_next_data* cqd = static_cast DATA_FROM_CQ(cq); @@ -741,8 +742,8 @@ static void cq_end_op_for_next( gpr_mu_unlock(cq->mu); if (kick_error != GRPC_ERROR_NONE) { - const char* msg = grpc_error_string(kick_error); - gpr_log(GPR_ERROR, "Kick failed: %s", msg); + gpr_log(GPR_ERROR, "Kick failed: %s", + grpc_error_std_string(kick_error).c_str()); GRPC_ERROR_UNREF(kick_error); } } @@ -782,14 +783,15 @@ static void cq_end_op_for_pluck( if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace) || (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures) && error != GRPC_ERROR_NONE)) { - const char* errmsg = grpc_error_string(error); + std::string errmsg = grpc_error_std_string(error).c_str(); GRPC_API_TRACE( "cq_end_op_for_pluck(cq=%p, tag=%p, error=%s, " "done=%p, done_arg=%p, storage=%p)", - 6, (cq, tag, errmsg, done, done_arg, storage)); + 6, (cq, tag, errmsg.c_str(), done, done_arg, storage)); if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures) && error != GRPC_ERROR_NONE) { - gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, errmsg); + gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, + errmsg.c_str()); } } @@ -822,13 +824,10 @@ static void cq_end_op_for_pluck( grpc_error_handle kick_error = cq->poller_vtable->kick(POLLSET_FROM_CQ(cq), pluck_worker); - gpr_mu_unlock(cq->mu); - if (kick_error != GRPC_ERROR_NONE) { - const char* msg = grpc_error_string(kick_error); - gpr_log(GPR_ERROR, "Kick failed: %s", msg); - + gpr_log(GPR_ERROR, "Kick failed: %s", + grpc_error_std_string(kick_error).c_str()); GRPC_ERROR_UNREF(kick_error); } } @@ -853,14 +852,15 @@ static void cq_end_op_for_callback( if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace) || (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures) && error != GRPC_ERROR_NONE)) { - const char* errmsg = grpc_error_string(error); + std::string errmsg = grpc_error_std_string(error); GRPC_API_TRACE( "cq_end_op_for_callback(cq=%p, tag=%p, error=%s, " "done=%p, done_arg=%p, storage=%p)", - 6, (cq, tag, errmsg, done, done_arg, storage)); + 6, (cq, tag, errmsg.c_str(), done, done_arg, storage)); if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures) && error != GRPC_ERROR_NONE) { - gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, errmsg); + gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, + errmsg.c_str()); } } @@ -1062,9 +1062,8 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline, gpr_mu_unlock(cq->mu); if (err != GRPC_ERROR_NONE) { - const char* msg = grpc_error_string(err); - gpr_log(GPR_ERROR, "Completion queue next failed: %s", msg); - + gpr_log(GPR_ERROR, "Completion queue next failed: %s", + grpc_error_std_string(err).c_str()); GRPC_ERROR_UNREF(err); ret.type = GRPC_QUEUE_TIMEOUT; ret.success = 0; @@ -1305,9 +1304,8 @@ static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag, if (err != GRPC_ERROR_NONE) { del_plucker(cq, tag, &worker); gpr_mu_unlock(cq->mu); - const char* msg = grpc_error_string(err); - gpr_log(GPR_ERROR, "Completion queue pluck failed: %s", msg); - + gpr_log(GPR_ERROR, "Completion queue pluck failed: %s", + grpc_error_std_string(err).c_str()); GRPC_ERROR_UNREF(err); ret.type = GRPC_QUEUE_TIMEOUT; ret.success = 0; diff --git a/src/core/lib/transport/error_utils.cc b/src/core/lib/transport/error_utils.cc index f4d9e824bb6..e8f05550c96 100644 --- a/src/core/lib/transport/error_utils.cc +++ b/src/core/lib/transport/error_utils.cc @@ -97,7 +97,7 @@ void grpc_error_get_status(grpc_error_handle error, grpc_millis deadline, if (code != nullptr) *code = status; if (error_string != nullptr && status != GRPC_STATUS_OK) { - *error_string = gpr_strdup(grpc_error_string(error)); + *error_string = gpr_strdup(grpc_error_std_string(error).c_str()); } if (http_error != nullptr) { diff --git a/src/core/lib/transport/transport_op_string.cc b/src/core/lib/transport/transport_op_string.cc index 722a64ecb8d..49dec384ee6 100644 --- a/src/core/lib/transport/transport_op_string.cc +++ b/src/core/lib/transport/transport_op_string.cc @@ -109,7 +109,7 @@ std::string grpc_transport_stream_op_batch_string( if (op->cancel_stream) { out.push_back(absl::StrCat( " CANCEL:", - grpc_error_string(op->payload->cancel_stream.cancel_error))); + grpc_error_std_string(op->payload->cancel_stream.cancel_error))); } return absl::StrJoin(out, ""); @@ -131,13 +131,13 @@ std::string grpc_transport_op_string(grpc_transport_op* op) { } if (op->disconnect_with_error != GRPC_ERROR_NONE) { - out.push_back(absl::StrCat(" DISCONNECT:", - grpc_error_string(op->disconnect_with_error))); + out.push_back(absl::StrCat( + " DISCONNECT:", grpc_error_std_string(op->disconnect_with_error))); } if (op->goaway_error) { - out.push_back( - absl::StrCat(" SEND_GOAWAY:%s", grpc_error_string(op->goaway_error))); + out.push_back(absl::StrCat(" SEND_GOAWAY:%s", + grpc_error_std_string(op->goaway_error))); } if (op->set_accept_stream) { diff --git a/src/core/tsi/alts/handshaker/alts_handshaker_client.cc b/src/core/tsi/alts/handshaker/alts_handshaker_client.cc index 9bf7dbb9e50..ed70d812512 100644 --- a/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +++ b/src/core/tsi/alts/handshaker/alts_handshaker_client.cc @@ -451,7 +451,7 @@ static void on_status_received(void* arg, grpc_error_handle error) { "alts_grpc_handshaker_client:%p on_status_received " "status:%d details:|%s| error:|%s|", client, client->handshake_status_code, status_details, - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); gpr_free(status_details); } maybe_complete_tsi_next(client, true /* receive_status_finished */, diff --git a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc index e50139c727a..9cca8ab4726 100644 --- a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +++ b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc @@ -383,7 +383,7 @@ static void on_handshaker_service_resp_recv(void* arg, if (error != GRPC_ERROR_NONE) { gpr_log(GPR_ERROR, "ALTS handshaker on_handshaker_service_resp_recv error: %s", - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); success = false; } alts_handshaker_client_handle_response(client, success); diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index d046fc4b57f..be99d54272f 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -232,7 +232,7 @@ grpc::Status StsCredentialsOptionsFromEnv(StsCredentialsOptions* options) { error = grpc_load_file(sts_creds_path, 1, &json_string); if (error != GRPC_ERROR_NONE) { status = - grpc::Status(grpc::StatusCode::NOT_FOUND, grpc_error_string(error)); + grpc::Status(grpc::StatusCode::NOT_FOUND, grpc_error_std_string(error)); return cleanup(); } status = StsCredentialsOptionsFromJson( diff --git a/src/cpp/common/validate_service_config.cc b/src/cpp/common/validate_service_config.cc index 0bc22d2d988..cac39ad98eb 100644 --- a/src/cpp/common/validate_service_config.cc +++ b/src/cpp/common/validate_service_config.cc @@ -30,7 +30,7 @@ std::string ValidateServiceConfigJSON(const std::string& service_config_json) { service_config_json.c_str(), &error); std::string return_value; if (error != GRPC_ERROR_NONE) { - return_value = grpc_error_string(error); + return_value = grpc_error_std_string(error); GRPC_ERROR_UNREF(error); } grpc_shutdown(); diff --git a/test/core/channel/channelz_test.cc b/test/core/channel/channelz_test.cc index 3dd554fe9e6..cc17a333b6a 100644 --- a/test/core/channel/channelz_test.cc +++ b/test/core/channel/channelz_test.cc @@ -107,7 +107,7 @@ void ValidateGetTopChannels(size_t expected_channels) { json_str.c_str()); grpc_error_handle error = GRPC_ERROR_NONE; Json parsed_json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); ASSERT_EQ(parsed_json.type(), Json::Type::OBJECT); // This check will naturally have to change when we support pagination. // tracked: https://github.com/grpc/grpc/issues/16019. @@ -127,7 +127,7 @@ void ValidateGetServers(size_t expected_servers) { json_str.c_str()); grpc_error_handle error = GRPC_ERROR_NONE; Json parsed_json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); ASSERT_EQ(parsed_json.type(), Json::Type::OBJECT); // This check will naturally have to change when we support pagination. // tracked: https://github.com/grpc/grpc/issues/16019. @@ -209,7 +209,7 @@ void ValidateCounters(const std::string& json_str, const ValidateChannelDataArgs& args) { grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); ASSERT_EQ(json.type(), Json::Type::OBJECT); Json::Object* object = json.mutable_object(); Json& data = (*object)["data"]; @@ -367,7 +367,7 @@ TEST_F(ChannelzRegistryBasedTest, GetTopChannelsPagination) { json_str.c_str()); grpc_error_handle error = GRPC_ERROR_NONE; Json parsed_json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); ASSERT_EQ(parsed_json.type(), Json::Type::OBJECT); // 100 is the pagination limit. ValidateJsonArraySize((*parsed_json.mutable_object())["channel"], 100); @@ -378,7 +378,7 @@ TEST_F(ChannelzRegistryBasedTest, GetTopChannelsPagination) { json_str.c_str()); error = GRPC_ERROR_NONE; parsed_json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); ASSERT_EQ(parsed_json.type(), Json::Type::OBJECT); ValidateJsonArraySize((*parsed_json.mutable_object())["channel"], 50); ValidateJsonEnd(parsed_json, true); @@ -392,7 +392,7 @@ TEST_F(ChannelzRegistryBasedTest, GetTopChannelsUuidCheck) { std::string json_str = ChannelzRegistry::GetTopChannels(0); grpc_error_handle error = GRPC_ERROR_NONE; Json parsed_json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); ASSERT_EQ(parsed_json.type(), Json::Type::OBJECT); Json& array = (*parsed_json.mutable_object())["channel"]; ValidateJsonArraySize(array, kNumChannels); @@ -412,7 +412,7 @@ TEST_F(ChannelzRegistryBasedTest, GetTopChannelsMiddleUuidCheck) { std::string json_str = ChannelzRegistry::GetTopChannels(kMidQuery); grpc_error_handle error = GRPC_ERROR_NONE; Json parsed_json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); ASSERT_EQ(parsed_json.type(), Json::Type::OBJECT); Json& array = (*parsed_json.mutable_object())["channel"]; ValidateJsonArraySize(array, kNumChannels - kMidQuery + 1); @@ -434,7 +434,7 @@ TEST_F(ChannelzRegistryBasedTest, GetTopChannelsNoHitUuid) { std::string json_str = ChannelzRegistry::GetTopChannels(45); grpc_error_handle error = GRPC_ERROR_NONE; Json parsed_json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); ASSERT_EQ(parsed_json.type(), Json::Type::OBJECT); Json& array = (*parsed_json.mutable_object())["channel"]; ValidateJsonArraySize(array, 10); @@ -455,7 +455,7 @@ TEST_F(ChannelzRegistryBasedTest, GetTopChannelsMoreGaps) { std::string json_str = ChannelzRegistry::GetTopChannels(2); grpc_error_handle error = GRPC_ERROR_NONE; Json parsed_json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); ASSERT_EQ(parsed_json.type(), Json::Type::OBJECT); Json array = (*parsed_json.mutable_object())["channel"]; ValidateJsonArraySize(array, 2); @@ -465,7 +465,7 @@ TEST_F(ChannelzRegistryBasedTest, GetTopChannelsMoreGaps) { json_str = ChannelzRegistry::GetTopChannels(4); error = GRPC_ERROR_NONE; parsed_json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); ASSERT_EQ(parsed_json.type(), Json::Type::OBJECT); array = (*parsed_json.mutable_object())["channel"]; ValidateJsonArraySize(array, 1); @@ -488,7 +488,7 @@ TEST_F(ChannelzRegistryBasedTest, GetTopChannelsUuidAfterCompaction) { std::string json_str = ChannelzRegistry::GetTopChannels(0); grpc_error_handle error = GRPC_ERROR_NONE; Json parsed_json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); ASSERT_EQ(parsed_json.type(), Json::Type::OBJECT); Json& array = (*parsed_json.mutable_object())["channel"]; ValidateJsonArraySize(array, kLoopIterations); diff --git a/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc b/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc index 3954a786522..8e2bfd0962c 100644 --- a/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc +++ b/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc @@ -213,7 +213,8 @@ class ResultHandler : public grpc_core::Resolver::ResultHandler { } void ReturnError(grpc_error_handle error) override { - gpr_log(GPR_ERROR, "resolver returned error: %s", grpc_error_string(error)); + gpr_log(GPR_ERROR, "resolver returned error: %s", + grpc_error_std_string(error).c_str()); GPR_ASSERT(false); } diff --git a/test/core/client_channel/service_config_test.cc b/test/core/client_channel/service_config_test.cc index f98e3754228..fb5e554f8c5 100644 --- a/test/core/client_channel/service_config_test.cc +++ b/test/core/client_channel/service_config_test.cc @@ -165,7 +165,7 @@ TEST_F(ServiceConfigTest, ErrorCheck1) { const char* test_json = ""; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex("JSON parse error")); GRPC_ERROR_UNREF(error); } @@ -174,7 +174,7 @@ TEST_F(ServiceConfigTest, BasicTest1) { const char* test_json = "{}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - EXPECT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + EXPECT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); } TEST_F(ServiceConfigTest, SkipMethodConfigWithNoNameOrEmptyName) { @@ -186,7 +186,7 @@ TEST_F(ServiceConfigTest, SkipMethodConfigWithNoNameOrEmptyName) { "]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( grpc_slice_from_static_string("/TestServ/TestMethod")); ASSERT_NE(vector_ptr, nullptr); @@ -203,7 +203,7 @@ TEST_F(ServiceConfigTest, ErrorDuplicateMethodConfigNames) { grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT( - grpc_error_string(error), + grpc_error_std_string(error), ::testing::ContainsRegex("Service config parsing error.*referenced_errors" ".*Method Params.*referenced_errors" ".*methodConfig.*referenced_errors" @@ -220,7 +220,7 @@ TEST_F(ServiceConfigTest, ErrorDuplicateMethodConfigNamesWithNullMethod) { grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT( - grpc_error_string(error), + grpc_error_std_string(error), ::testing::ContainsRegex("Service config parsing error.*referenced_errors" ".*Method Params.*referenced_errors" ".*methodConfig.*referenced_errors" @@ -237,7 +237,7 @@ TEST_F(ServiceConfigTest, ErrorDuplicateMethodConfigNamesWithEmptyMethod) { grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT( - grpc_error_string(error), + grpc_error_std_string(error), ::testing::ContainsRegex("Service config parsing error.*referenced_errors" ".*Method Params.*referenced_errors" ".*methodConfig.*referenced_errors" @@ -254,7 +254,7 @@ TEST_F(ServiceConfigTest, ErrorDuplicateDefaultMethodConfigs) { grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT( - grpc_error_string(error), + grpc_error_std_string(error), ::testing::ContainsRegex("Service config parsing error.*referenced_errors" ".*Method Params.*referenced_errors" ".*methodConfig.*referenced_errors" @@ -271,7 +271,7 @@ TEST_F(ServiceConfigTest, ErrorDuplicateDefaultMethodConfigsWithNullService) { grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT( - grpc_error_string(error), + grpc_error_std_string(error), ::testing::ContainsRegex("Service config parsing error.*referenced_errors" ".*Method Params.*referenced_errors" ".*methodConfig.*referenced_errors" @@ -288,7 +288,7 @@ TEST_F(ServiceConfigTest, ErrorDuplicateDefaultMethodConfigsWithEmptyService) { grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT( - grpc_error_string(error), + grpc_error_std_string(error), ::testing::ContainsRegex("Service config parsing error.*referenced_errors" ".*Method Params.*referenced_errors" ".*methodConfig.*referenced_errors" @@ -301,14 +301,14 @@ TEST_F(ServiceConfigTest, ValidMethodConfig) { "{\"methodConfig\": [{\"name\":[{\"service\":\"TestServ\"}]}]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - EXPECT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + EXPECT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); } TEST_F(ServiceConfigTest, Parser1BasicTest1) { const char* test_json = "{\"global_param\":5}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); EXPECT_EQ((static_cast(svc_cfg->GetGlobalParsedConfig(0))) ->value(), 5); @@ -321,7 +321,7 @@ TEST_F(ServiceConfigTest, Parser1BasicTest2) { const char* test_json = "{\"global_param\":1000}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); EXPECT_EQ((static_cast(svc_cfg->GetGlobalParsedConfig(0))) ->value(), 1000); @@ -334,7 +334,7 @@ TEST_F(ServiceConfigTest, Parser1DisabledViaChannelArg) { const char* test_json = "{\"global_param\":5}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(&args, test_json, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); EXPECT_EQ(svc_cfg->GetGlobalParsedConfig(0), nullptr); } @@ -342,7 +342,7 @@ TEST_F(ServiceConfigTest, Parser1ErrorInvalidType) { const char* test_json = "{\"global_param\":\"5\"}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex(absl::StrCat( "Service config parsing error.*referenced_errors.*" "Global Params.*referenced_errors.*", @@ -354,7 +354,7 @@ TEST_F(ServiceConfigTest, Parser1ErrorInvalidValue) { const char* test_json = "{\"global_param\":-5}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex(absl::StrCat( "Service config parsing error.*referenced_errors.*" "Global Params.*referenced_errors.*", @@ -368,7 +368,7 @@ TEST_F(ServiceConfigTest, Parser2BasicTest) { "\"method_param\":5}]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( grpc_slice_from_static_string("/TestServ/TestMethod")); ASSERT_NE(vector_ptr, nullptr); @@ -385,7 +385,7 @@ TEST_F(ServiceConfigTest, Parser2DisabledViaChannelArg) { "\"method_param\":5}]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(&args, test_json, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( grpc_slice_from_static_string("/TestServ/TestMethod")); ASSERT_NE(vector_ptr, nullptr); @@ -399,7 +399,7 @@ TEST_F(ServiceConfigTest, Parser2ErrorInvalidType) { "\"method_param\":\"5\"}]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex(absl::StrCat( "Service config parsing error.*referenced_errors\":\\[.*" "Method Params.*referenced_errors.*methodConfig.*" @@ -414,7 +414,7 @@ TEST_F(ServiceConfigTest, Parser2ErrorInvalidValue) { "\"method_param\":-5}]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex(absl::StrCat( "Service config parsing error.*referenced_errors\":\\[.*" "Method Params.*referenced_errors.*methodConfig.*" @@ -443,7 +443,7 @@ TEST_F(ErroredParsersScopingTest, GlobalParams) { grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT( - grpc_error_string(error), + grpc_error_std_string(error), ::testing::ContainsRegex(absl::StrCat( "Service config parsing error.*referenced_errors\":\\[.*" "Global Params.*referenced_errors.*", @@ -456,7 +456,7 @@ TEST_F(ErroredParsersScopingTest, MethodParams) { grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT( - grpc_error_string(error), + grpc_error_std_string(error), ::testing::ContainsRegex(absl::StrCat( "Service config parsing error.*referenced_errors\":\\[.*" "Global Params.*referenced_errors.*", @@ -487,7 +487,7 @@ TEST_F(ClientChannelParserTest, ValidLoadBalancingConfigPickFirst) { const char* test_json = "{\"loadBalancingConfig\": [{\"pick_first\":{}}]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* parsed_config = static_cast( svc_cfg->GetGlobalParsedConfig(0)); @@ -500,7 +500,7 @@ TEST_F(ClientChannelParserTest, ValidLoadBalancingConfigRoundRobin) { "{\"loadBalancingConfig\": [{\"round_robin\":{}}, {}]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); auto parsed_config = static_cast( svc_cfg->GetGlobalParsedConfig(0)); @@ -514,7 +514,7 @@ TEST_F(ClientChannelParserTest, ValidLoadBalancingConfigGrpclb) { "[{\"grpclb\":{\"childPolicy\":[{\"pick_first\":{}}]}}]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* parsed_config = static_cast( svc_cfg->GetGlobalParsedConfig(0)); @@ -537,7 +537,7 @@ TEST_F(ClientChannelParserTest, ValidLoadBalancingConfigXds) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* parsed_config = static_cast( svc_cfg->GetGlobalParsedConfig(0)); @@ -549,7 +549,7 @@ TEST_F(ClientChannelParserTest, UnknownLoadBalancingConfig) { const char* test_json = "{\"loadBalancingConfig\": [{\"unknown\":{}}]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error.*referenced_errors.*" "Global Params.*referenced_errors.*" @@ -567,7 +567,7 @@ TEST_F(ClientChannelParserTest, InvalidGrpclbLoadBalancingConfig) { "]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error.*referenced_errors.*" "Global Params.*referenced_errors.*" @@ -583,7 +583,7 @@ TEST_F(ClientChannelParserTest, ValidLoadBalancingPolicy) { const char* test_json = "{\"loadBalancingPolicy\":\"pick_first\"}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* parsed_config = static_cast( svc_cfg->GetGlobalParsedConfig(0)); @@ -594,7 +594,7 @@ TEST_F(ClientChannelParserTest, ValidLoadBalancingPolicyAllCaps) { const char* test_json = "{\"loadBalancingPolicy\":\"PICK_FIRST\"}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* parsed_config = static_cast( svc_cfg->GetGlobalParsedConfig(0)); @@ -605,7 +605,7 @@ TEST_F(ClientChannelParserTest, UnknownLoadBalancingPolicy) { const char* test_json = "{\"loadBalancingPolicy\":\"unknown\"}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error.*referenced_errors.*" "Global Params.*referenced_errors.*" @@ -619,7 +619,7 @@ TEST_F(ClientChannelParserTest, LoadBalancingPolicyXdsNotAllowed) { "{\"loadBalancingPolicy\":\"xds_cluster_resolver_experimental\"}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error.*referenced_errors.*" "Global Params.*referenced_errors.*" @@ -642,7 +642,7 @@ TEST_F(ClientChannelParserTest, ValidTimeout) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( grpc_slice_from_static_string("/TestServ/TestMethod")); ASSERT_NE(vector_ptr, nullptr); @@ -665,7 +665,7 @@ TEST_F(ClientChannelParserTest, InvalidTimeout) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error.*referenced_errors.*" "Method Params.*referenced_errors.*" @@ -688,7 +688,7 @@ TEST_F(ClientChannelParserTest, ValidWaitForReady) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( grpc_slice_from_static_string("/TestServ/TestMethod")); ASSERT_NE(vector_ptr, nullptr); @@ -717,7 +717,7 @@ TEST_F(ClientChannelParserTest, InvalidWaitForReady) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error.*referenced_errors.*" "Method Params.*referenced_errors.*" @@ -736,7 +736,7 @@ TEST_F(ClientChannelParserTest, ValidHealthCheck) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* parsed_config = static_cast( svc_cfg->GetGlobalParsedConfig(0)); @@ -757,7 +757,7 @@ TEST_F(ClientChannelParserTest, InvalidHealthCheckMultipleEntries) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "JSON parsing failed.*referenced_errors.*" "duplicate key \"healthCheckConfig\" at index 104")); @@ -789,7 +789,7 @@ TEST_F(RetryParserTest, ValidRetryThrottling) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* parsed_config = static_cast( svc_cfg->GetGlobalParsedConfig(0)); @@ -806,7 +806,7 @@ TEST_F(RetryParserTest, RetryThrottlingMissingFields) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error.*referenced_errors.*" "Global Params.*referenced_errors.*" @@ -826,7 +826,7 @@ TEST_F(RetryParserTest, InvalidRetryThrottlingNegativeMaxTokens) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error.*referenced_errors.*" "Global Params.*referenced_errors.*" @@ -846,7 +846,7 @@ TEST_F(RetryParserTest, InvalidRetryThrottlingInvalidTokenRatio) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error.*referenced_errors.*" "Global Params.*referenced_errors.*" @@ -874,7 +874,7 @@ TEST_F(RetryParserTest, ValidRetryPolicy) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( grpc_slice_from_static_string("/TestServ/TestMethod")); ASSERT_NE(vector_ptr, nullptr); @@ -908,7 +908,7 @@ TEST_F(RetryParserTest, InvalidRetryPolicyMaxAttempts) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error.*referenced_errors.*" "Method Params.*referenced_errors.*" @@ -936,7 +936,7 @@ TEST_F(RetryParserTest, InvalidRetryPolicyInitialBackoff) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error.*referenced_errors.*" "Method Params.*referenced_errors.*" @@ -965,7 +965,7 @@ TEST_F(RetryParserTest, InvalidRetryPolicyMaxBackoff) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error.*referenced_errors.*" "Method Params.*referenced_errors.*" @@ -994,7 +994,7 @@ TEST_F(RetryParserTest, InvalidRetryPolicyBackoffMultiplier) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error.*referenced_errors.*" "Method Params.*referenced_errors.*" @@ -1022,7 +1022,7 @@ TEST_F(RetryParserTest, InvalidRetryPolicyRetryableStatusCodes) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error.*referenced_errors.*" "Method Params.*referenced_errors.*" @@ -1060,7 +1060,7 @@ TEST_F(MessageSizeParserTest, Valid) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( grpc_slice_from_static_string("/TestServ/TestMethod")); ASSERT_NE(vector_ptr, nullptr); @@ -1083,7 +1083,7 @@ TEST_F(MessageSizeParserTest, InvalidMaxRequestMessageBytes) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error.*referenced_errors.*" "Method Params.*referenced_errors.*" @@ -1105,7 +1105,7 @@ TEST_F(MessageSizeParserTest, InvalidMaxResponseMessageBytes) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error.*referenced_errors.*" "Method Params.*referenced_errors.*" diff --git a/test/core/end2end/bad_server_response_test.cc b/test/core/end2end/bad_server_response_test.cc index 4ab659b2912..b4e27075d7d 100644 --- a/test/core/end2end/bad_server_response_test.cc +++ b/test/core/end2end/bad_server_response_test.cc @@ -118,7 +118,8 @@ static void handle_write() { static void handle_read(void* /*arg*/, grpc_error_handle error) { if (error != GRPC_ERROR_NONE) { - gpr_log(GPR_ERROR, "handle_read error: %s", grpc_error_string(error)); + gpr_log(GPR_ERROR, "handle_read error: %s", + grpc_error_std_string(error).c_str()); return; } state.incoming_data_length += state.temp_incoming_buffer.length; diff --git a/test/core/end2end/fixtures/http_proxy_fixture.cc b/test/core/end2end/fixtures/http_proxy_fixture.cc index fe5c3648284..e28bafb2175 100644 --- a/test/core/end2end/fixtures/http_proxy_fixture.cc +++ b/test/core/end2end/fixtures/http_proxy_fixture.cc @@ -172,7 +172,7 @@ static void on_read_request_done_locked(void* arg, grpc_error_handle error); static void proxy_connection_failed(proxy_connection* conn, failure_type failure, const char* prefix, grpc_error_handle error) { - gpr_log(GPR_INFO, "%s: %s", prefix, grpc_error_string(error)); + gpr_log(GPR_INFO, "%s: %s", prefix, grpc_error_std_string(error).c_str()); // Decide whether we should shut down the client and server. bool shutdown_client = false; bool shutdown_server = false; @@ -459,7 +459,7 @@ static bool proxy_auth_header_matches(char* proxy_auth_header_val, static void on_read_request_done_locked(void* arg, grpc_error_handle error) { proxy_connection* conn = static_cast(arg); gpr_log(GPR_DEBUG, "on_read_request_done: %p %s", conn, - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); if (error != GRPC_ERROR_NONE) { proxy_connection_failed(conn, SETUP_FAILED, "HTTP proxy read request", GRPC_ERROR_REF(error)); diff --git a/test/core/http/httpcli_test.cc b/test/core/http/httpcli_test.cc index 2956202627f..f9fd3114807 100644 --- a/test/core/http/httpcli_test.cc +++ b/test/core/http/httpcli_test.cc @@ -48,7 +48,7 @@ static void on_finish(void* arg, grpc_error_handle error) { grpc_http_response* response = static_cast(arg); GPR_ASSERT(response); gpr_log(GPR_INFO, "response status=%d error=%s", response->status, - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); GPR_ASSERT(response->status == 200); GPR_ASSERT(response->body_length == strlen(expect)); GPR_ASSERT(0 == memcmp(expect, response->body, response->body_length)); diff --git a/test/core/http/httpscli_test.cc b/test/core/http/httpscli_test.cc index 65fb6a801b3..a94a67b5f76 100644 --- a/test/core/http/httpscli_test.cc +++ b/test/core/http/httpscli_test.cc @@ -51,7 +51,7 @@ static void on_finish(void* arg, grpc_error_handle error) { grpc_http_response* response = static_cast(arg); GPR_ASSERT(response); gpr_log(GPR_INFO, "response status=%d error=%s", response->status, - grpc_error_string(error)); + grpc_error_std_string(error).c_str()); GPR_ASSERT(response->status == 200); GPR_ASSERT(response->body_length == strlen(expect)); GPR_ASSERT(0 == memcmp(expect, response->body, response->body_length)); diff --git a/test/core/iomgr/error_test.cc b/test/core/iomgr/error_test.cc index 52e4c9f69a5..e50a5f0140e 100644 --- a/test/core/iomgr/error_test.cc +++ b/test/core/iomgr/error_test.cc @@ -145,7 +145,7 @@ static void print_error_string() { error = grpc_error_set_int(error, GRPC_ERROR_INT_SIZE, 666); error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, grpc_slice_from_static_string("message")); - // gpr_log(GPR_DEBUG, "%s", grpc_error_string(error)); + // gpr_log(GPR_DEBUG, "%s", grpc_error_std_string(error).c_str()); GRPC_ERROR_UNREF(error); } diff --git a/test/core/iomgr/ios/CFStreamTests/CFStreamClientTests.mm b/test/core/iomgr/ios/CFStreamTests/CFStreamClientTests.mm index 82f65ce34a1..a826f0469c6 100644 --- a/test/core/iomgr/ios/CFStreamTests/CFStreamClientTests.mm +++ b/test/core/iomgr/ios/CFStreamTests/CFStreamClientTests.mm @@ -55,8 +55,7 @@ static void must_succeed(void* arg, grpc_error_handle error) { static void must_fail(void* arg, grpc_error_handle error) { GPR_ASSERT(g_connecting == nullptr); GPR_ASSERT(error != GRPC_ERROR_NONE); - const char* error_str = grpc_error_string(error); - NSLog(@"%s", error_str); + NSLog(@"%s", grpc_error_std_string(error).c_str()); finish_connection(); } diff --git a/test/core/iomgr/tcp_server_posix_test.cc b/test/core/iomgr/tcp_server_posix_test.cc index 03944fcf3bd..549bb8cffad 100644 --- a/test/core/iomgr/tcp_server_posix_test.cc +++ b/test/core/iomgr/tcp_server_posix_test.cc @@ -373,7 +373,7 @@ static void test_connect(size_t num_connects, continue; } gpr_log(GPR_ERROR, "Failed to connect to %s: %s", dst.str, - grpc_error_string(err)); + grpc_error_std_string(err).c_str()); GPR_ASSERT(test_dst_addrs); dst_addrs->addrs[dst_idx].addr.len = 0; GRPC_ERROR_UNREF(err); diff --git a/test/core/json/json_test.cc b/test/core/json/json_test.cc index 37c17ca2e41..c724f1b6342 100644 --- a/test/core/json/json_test.cc +++ b/test/core/json/json_test.cc @@ -77,7 +77,7 @@ void RunSuccessTest(const char* input, const Json& expected, gpr_log(GPR_INFO, "parsing string \"%s\" - should succeed", input); grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(input, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); ValidateValue(json, expected); std::string output = json.Dump(); EXPECT_EQ(output, expected_output); @@ -167,7 +167,7 @@ void RunParseFailureTest(const char* input) { gpr_log(GPR_INFO, "parsing string \"%s\" - should fail", input); grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(input, &error); - gpr_log(GPR_INFO, "error: %s", grpc_error_string(error)); + gpr_log(GPR_INFO, "error: %s", grpc_error_std_string(error).c_str()); EXPECT_NE(error, GRPC_ERROR_NONE); GRPC_ERROR_UNREF(error); } diff --git a/test/core/security/credentials_test.cc b/test/core/security/credentials_test.cc index 44017dd189a..0533247a182 100644 --- a/test/core/security/credentials_test.cc +++ b/test/core/security/credentials_test.cc @@ -446,8 +446,8 @@ static void check_metadata(const expected_md* expected, static void check_request_metadata(void* arg, grpc_error_handle error) { request_metadata_state* state = static_cast(arg); gpr_log(GPR_INFO, "expected_error: %s", - grpc_error_string(state->expected_error)); - gpr_log(GPR_INFO, "actual_error: %s", grpc_error_string(error)); + grpc_error_std_string(state->expected_error).c_str()); + gpr_log(GPR_INFO, "actual_error: %s", grpc_error_std_string(error).c_str()); if (state->expected_error == GRPC_ERROR_NONE) { GPR_ASSERT(error == GRPC_ERROR_NONE); } else { diff --git a/test/core/security/json_token_test.cc b/test/core/security/json_token_test.cc index 99851e112d1..1ded259b7f4 100644 --- a/test/core/security/json_token_test.cc +++ b/test/core/security/json_token_test.cc @@ -219,7 +219,8 @@ static Json parse_json_part_from_jwt(const char* str, size_t len) { absl::string_view string = grpc_core::StringViewFromSlice(slice); Json json = Json::Parse(string, &error); if (error != GRPC_ERROR_NONE) { - gpr_log(GPR_ERROR, "JSON parse error: %s", grpc_error_string(error)); + gpr_log(GPR_ERROR, "JSON parse error: %s", + grpc_error_std_string(error).c_str()); GRPC_ERROR_UNREF(error); } grpc_slice_unref(slice); diff --git a/test/core/security/jwt_verifier_test.cc b/test/core/security/jwt_verifier_test.cc index dec36acc656..21ed63fcfd1 100644 --- a/test/core/security/jwt_verifier_test.cc +++ b/test/core/security/jwt_verifier_test.cc @@ -210,7 +210,8 @@ static void test_claims_success(void) { grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(claims_without_time_constraint, &error); if (error != GRPC_ERROR_NONE) { - gpr_log(GPR_ERROR, "JSON parse error: %s", grpc_error_string(error)); + gpr_log(GPR_ERROR, "JSON parse error: %s", + grpc_error_std_string(error).c_str()); } GPR_ASSERT(error == GRPC_ERROR_NONE); GPR_ASSERT(json.type() == Json::Type::OBJECT); @@ -232,7 +233,8 @@ static void test_expired_claims_failure(void) { grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(expired_claims, &error); if (error != GRPC_ERROR_NONE) { - gpr_log(GPR_ERROR, "JSON parse error: %s", grpc_error_string(error)); + gpr_log(GPR_ERROR, "JSON parse error: %s", + grpc_error_std_string(error).c_str()); } GPR_ASSERT(error == GRPC_ERROR_NONE); GPR_ASSERT(json.type() == Json::Type::OBJECT); @@ -260,7 +262,8 @@ static void test_invalid_claims_failure(void) { grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(invalid_claims, &error); if (error != GRPC_ERROR_NONE) { - gpr_log(GPR_ERROR, "JSON parse error: %s", grpc_error_string(error)); + gpr_log(GPR_ERROR, "JSON parse error: %s", + grpc_error_std_string(error).c_str()); } GPR_ASSERT(error == GRPC_ERROR_NONE); GPR_ASSERT(json.type() == Json::Type::OBJECT); @@ -273,7 +276,8 @@ static void test_bad_audience_claims_failure(void) { grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(claims_without_time_constraint, &error); if (error != GRPC_ERROR_NONE) { - gpr_log(GPR_ERROR, "JSON parse error: %s", grpc_error_string(error)); + gpr_log(GPR_ERROR, "JSON parse error: %s", + grpc_error_std_string(error).c_str()); } GPR_ASSERT(error == GRPC_ERROR_NONE); GPR_ASSERT(json.type() == Json::Type::OBJECT); @@ -290,7 +294,8 @@ static void test_bad_subject_claims_failure(void) { grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(claims_with_bad_subject, &error); if (error != GRPC_ERROR_NONE) { - gpr_log(GPR_ERROR, "JSON parse error: %s", grpc_error_string(error)); + gpr_log(GPR_ERROR, "JSON parse error: %s", + grpc_error_std_string(error).c_str()); } GPR_ASSERT(error == GRPC_ERROR_NONE); GPR_ASSERT(json.type() == Json::Type::OBJECT); diff --git a/test/core/security/oauth2_utils.cc b/test/core/security/oauth2_utils.cc index 03118cbc377..536696b4c5a 100644 --- a/test/core/security/oauth2_utils.cc +++ b/test/core/security/oauth2_utils.cc @@ -45,7 +45,8 @@ static void on_oauth2_response(void* arg, grpc_error_handle error) { char* token = nullptr; grpc_slice token_slice; if (error != GRPC_ERROR_NONE) { - gpr_log(GPR_ERROR, "Fetching token failed: %s", grpc_error_string(error)); + gpr_log(GPR_ERROR, "Fetching token failed: %s", + grpc_error_std_string(error).c_str()); } else { GPR_ASSERT(request->md_array.size == 1); token_slice = GRPC_MDVALUE(request->md_array.md[0]); diff --git a/test/core/security/print_google_default_creds_token.cc b/test/core/security/print_google_default_creds_token.cc index 41e3be89230..0d6c7b79a36 100644 --- a/test/core/security/print_google_default_creds_token.cc +++ b/test/core/security/print_google_default_creds_token.cc @@ -44,7 +44,8 @@ typedef struct { static void on_metadata_response(void* arg, grpc_error_handle error) { synchronizer* sync = static_cast(arg); if (error != GRPC_ERROR_NONE) { - fprintf(stderr, "Fetching token failed: %s\n", grpc_error_string(error)); + fprintf(stderr, "Fetching token failed: %s\n", + grpc_error_std_string(error).c_str()); fflush(stderr); } else { char* token; diff --git a/test/core/transport/chttp2/settings_timeout_test.cc b/test/core/transport/chttp2/settings_timeout_test.cc index 28314b8235d..b9790208578 100644 --- a/test/core/transport/chttp2/settings_timeout_test.cc +++ b/test/core/transport/chttp2/settings_timeout_test.cc @@ -106,7 +106,7 @@ class Client { grpc_resolved_addresses* server_addresses = nullptr; grpc_error_handle error = grpc_blocking_resolve_address(server_address_, "80", &server_addresses); - ASSERT_EQ(GRPC_ERROR_NONE, error) << grpc_error_string(error); + ASSERT_EQ(GRPC_ERROR_NONE, error) << grpc_error_std_string(error); ASSERT_GE(server_addresses->naddrs, 1UL); pollset_ = static_cast(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(pollset_, &mu_); @@ -181,7 +181,8 @@ class Client { private: static void OnEventDone(void* arg, grpc_error_handle error) { - gpr_log(GPR_INFO, "OnEventDone(): %s", grpc_error_string(error)); + gpr_log(GPR_INFO, "OnEventDone(): %s", + grpc_error_std_string(error).c_str()); EventState* state = static_cast(arg); state->error_ = GRPC_ERROR_REF(error); gpr_atm_rel_store(&state->done_atm_, 1); diff --git a/test/core/util/port_server_client.cc b/test/core/util/port_server_client.cc index 91a0bc71f09..3747187e5bf 100644 --- a/test/core/util/port_server_client.cc +++ b/test/core/util/port_server_client.cc @@ -136,9 +136,8 @@ static void got_port_from_server(void* arg, grpc_error_handle error) { if (error != GRPC_ERROR_NONE) { failed = 1; - const char* msg = grpc_error_string(error); - gpr_log(GPR_DEBUG, "failed port pick from server: retrying [%s]", msg); - + gpr_log(GPR_DEBUG, "failed port pick from server: retrying [%s]", + grpc_error_std_string(error).c_str()); } else if (response->status != 200) { failed = 1; gpr_log(GPR_DEBUG, "failed port pick from server: status=%d", diff --git a/test/core/xds/file_watcher_certificate_provider_factory_test.cc b/test/core/xds/file_watcher_certificate_provider_factory_test.cc index c82e8e30fed..5157634ec7f 100644 --- a/test/core/xds/file_watcher_certificate_provider_factory_test.cc +++ b/test/core/xds/file_watcher_certificate_provider_factory_test.cc @@ -47,10 +47,10 @@ TEST(FileWatcherConfigTest, Basic) { kIdentityCertFile, kPrivateKeyFile, kRootCertFile, kRefreshInterval); grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); auto config = FileWatcherCertificateProviderFactory::Config::Parse(json, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); EXPECT_EQ(config->identity_cert_file(), kIdentityCertFile); EXPECT_EQ(config->private_key_file(), kPrivateKeyFile); EXPECT_EQ(config->root_cert_file(), kRootCertFile); @@ -67,10 +67,10 @@ TEST(FileWatcherConfigTest, DefaultRefreshInterval) { kIdentityCertFile, kPrivateKeyFile, kRootCertFile); grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); auto config = FileWatcherCertificateProviderFactory::Config::Parse(json, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); EXPECT_EQ(config->identity_cert_file(), kIdentityCertFile); EXPECT_EQ(config->private_key_file(), kPrivateKeyFile); EXPECT_EQ(config->root_cert_file(), kRootCertFile); @@ -85,10 +85,10 @@ TEST(FileWatcherConfigTest, OnlyRootCertificatesFileProvided) { kRootCertFile); grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); auto config = FileWatcherCertificateProviderFactory::Config::Parse(json, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); EXPECT_TRUE(config->identity_cert_file().empty()); EXPECT_TRUE(config->private_key_file().empty()); EXPECT_EQ(config->root_cert_file(), kRootCertFile); @@ -104,10 +104,10 @@ TEST(FileWatcherConfigTest, OnlyIdenityCertificatesAndPrivateKeyProvided) { kIdentityCertFile, kPrivateKeyFile); grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); auto config = FileWatcherCertificateProviderFactory::Config::Parse(json, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); EXPECT_EQ(config->identity_cert_file(), kIdentityCertFile); EXPECT_EQ(config->private_key_file(), kPrivateKeyFile); EXPECT_TRUE(config->root_cert_file().empty()); @@ -124,10 +124,10 @@ TEST(FileWatcherConfigTest, WrongTypes) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); auto config = FileWatcherCertificateProviderFactory::Config::Parse(json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "field:certificate_file error:type should be STRING.*" "field:private_key_file error:type should be STRING.*" @@ -146,10 +146,10 @@ TEST(FileWatcherConfigTest, IdentityCertProvidedButPrivateKeyMissing) { kIdentityCertFile); grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); auto config = FileWatcherCertificateProviderFactory::Config::Parse(json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "fields \"certificate_file\" and \"private_key_file\" must " "be both set or both unset.")); @@ -164,10 +164,10 @@ TEST(FileWatcherConfigTest, PrivateKeyProvidedButIdentityCertMissing) { kPrivateKeyFile); grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); auto config = FileWatcherCertificateProviderFactory::Config::Parse(json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "fields \"certificate_file\" and \"private_key_file\" must " "be both set or both unset.")); @@ -178,11 +178,11 @@ TEST(FileWatcherConfigTest, EmptyJsonObject) { std::string json_str = absl::StrFormat("{}"); grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); auto config = FileWatcherCertificateProviderFactory::Config::Parse(json, &error); EXPECT_THAT( - grpc_error_string(error), + grpc_error_std_string(error), ::testing::ContainsRegex("At least one of \"certificate_file\" and " "\"ca_certificate_file\" must be specified.")); GRPC_ERROR_UNREF(error); diff --git a/test/core/xds/google_mesh_ca_certificate_provider_factory_test.cc b/test/core/xds/google_mesh_ca_certificate_provider_factory_test.cc index 62478aaecfe..bf72df295b4 100644 --- a/test/core/xds/google_mesh_ca_certificate_provider_factory_test.cc +++ b/test/core/xds/google_mesh_ca_certificate_provider_factory_test.cc @@ -69,10 +69,10 @@ TEST(GoogleMeshCaConfigTest, Basic) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); auto config = GoogleMeshCaCertificateProviderFactory::Config::Parse(json, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); EXPECT_EQ(config->endpoint(), "newmeshca.googleapis.com"); EXPECT_EQ(config->sts_config().token_exchange_service_uri, "newsecuretoken.googleapis.com"); @@ -122,10 +122,10 @@ TEST(GoogleMeshCaConfigTest, Defaults) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); auto config = GoogleMeshCaCertificateProviderFactory::Config::Parse(json, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); EXPECT_EQ(config->endpoint(), "meshca.googleapis.com"); EXPECT_EQ(config->sts_config().token_exchange_service_uri, "securetoken.googleapis.com"); @@ -174,11 +174,11 @@ TEST(GoogleMeshCaConfigTest, WrongExpectedValues) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); auto config = GoogleMeshCaCertificateProviderFactory::Config::Parse(json, &error); EXPECT_THAT( - grpc_error_string(error), + grpc_error_std_string(error), ::testing::ContainsRegex("field:api_type error:Only GRPC is supported.*" "field:key_type error:Only RSA is supported")); GRPC_ERROR_UNREF(error); @@ -217,11 +217,11 @@ TEST(GoogleMeshCaConfigTest, WrongTypes) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); auto config = GoogleMeshCaCertificateProviderFactory::Config::Parse(json, &error); EXPECT_THAT( - grpc_error_string(error), + grpc_error_std_string(error), ::testing::ContainsRegex( "field:server.*field:api_type error:type should be STRING.*" "field:grpc_services.*field:google_grpc.*field:target_uri " @@ -261,11 +261,11 @@ TEST(GoogleMeshCaConfigTest, GrpcServicesNotAnArray) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); auto config = GoogleMeshCaCertificateProviderFactory::Config::Parse(json, &error); EXPECT_THAT( - grpc_error_string(error), + grpc_error_std_string(error), ::testing::ContainsRegex( "field:server.*field:grpc_services error:type should be ARRAY")); GRPC_ERROR_UNREF(error); @@ -286,11 +286,11 @@ TEST(GoogleMeshCaConfigTest, GoogleGrpcNotAnObject) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); auto config = GoogleMeshCaCertificateProviderFactory::Config::Parse(json, &error); EXPECT_THAT( - grpc_error_string(error), + grpc_error_std_string(error), ::testing::ContainsRegex("field:server.*field:grpc_services.*field:" "google_grpc error:type should be OBJECT")); GRPC_ERROR_UNREF(error); @@ -313,10 +313,10 @@ TEST(GoogleMeshCaConfigTest, CallCredentialsNotAnArray) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); auto config = GoogleMeshCaCertificateProviderFactory::Config::Parse(json, &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "field:server.*field:grpc_services.*field:google_grpc.*" "field:call_credentials error:type should be ARRAY")); @@ -342,11 +342,11 @@ TEST(GoogleMeshCaConfigTest, StsServiceNotAnObject) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); auto config = GoogleMeshCaCertificateProviderFactory::Config::Parse(json, &error); EXPECT_THAT( - grpc_error_string(error), + grpc_error_std_string(error), ::testing::ContainsRegex( "field:server.*field:grpc_services.*field:google_grpc.*field:" "call_credentials.*field:sts_service error:type should be OBJECT")); diff --git a/test/core/xds/xds_bootstrap_test.cc b/test/core/xds/xds_bootstrap_test.cc index 753b58300e5..09c8dd4c307 100644 --- a/test/core/xds/xds_bootstrap_test.cc +++ b/test/core/xds/xds_bootstrap_test.cc @@ -115,9 +115,9 @@ TEST_P(XdsBootstrapTest, Basic) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); XdsBootstrap bootstrap(std::move(json), &error); - EXPECT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + EXPECT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); EXPECT_EQ(bootstrap.server().server_uri, "fake:///lb"); EXPECT_EQ(bootstrap.server().channel_creds_type, "fake"); EXPECT_EQ(bootstrap.server().channel_creds_config.type(), @@ -157,9 +157,9 @@ TEST_P(XdsBootstrapTest, ValidWithoutNode) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); XdsBootstrap bootstrap(std::move(json), &error); - EXPECT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + EXPECT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); EXPECT_EQ(bootstrap.server().server_uri, "fake:///lb"); EXPECT_EQ(bootstrap.server().channel_creds_type, "fake"); EXPECT_EQ(bootstrap.node(), nullptr); @@ -177,9 +177,9 @@ TEST_P(XdsBootstrapTest, InsecureCreds) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); XdsBootstrap bootstrap(std::move(json), &error); - EXPECT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + EXPECT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); EXPECT_EQ(bootstrap.server().server_uri, "fake:///lb"); EXPECT_EQ(bootstrap.server().channel_creds_type, "insecure"); EXPECT_EQ(bootstrap.node(), nullptr); @@ -213,9 +213,9 @@ TEST_P(XdsBootstrapTest, GoogleDefaultCreds) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); XdsBootstrap bootstrap(std::move(json), &error); - EXPECT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + EXPECT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); EXPECT_EQ(bootstrap.server().server_uri, "fake:///lb"); EXPECT_EQ(bootstrap.server().channel_creds_type, "google_default"); EXPECT_EQ(bootstrap.node(), nullptr); @@ -232,9 +232,9 @@ TEST_P(XdsBootstrapTest, MissingChannelCreds) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); XdsBootstrap bootstrap(std::move(json), &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex("\"channel_creds\" field not present")); GRPC_ERROR_UNREF(error); } @@ -251,9 +251,9 @@ TEST_P(XdsBootstrapTest, NoKnownChannelCreds) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); XdsBootstrap bootstrap(std::move(json), &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "no known creds type found in \"channel_creds\"")); GRPC_ERROR_UNREF(error); @@ -262,9 +262,9 @@ TEST_P(XdsBootstrapTest, NoKnownChannelCreds) { TEST_P(XdsBootstrapTest, MissingXdsServers) { grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse("{}", &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); XdsBootstrap bootstrap(std::move(json), &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex("\"xds_servers\" field not present")); GRPC_ERROR_UNREF(error); } @@ -279,15 +279,15 @@ TEST_P(XdsBootstrapTest, TopFieldsWrongTypes) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); XdsBootstrap bootstrap(std::move(json), &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex("\"xds_servers\" field is not an array.*" "\"node\" field is not an object.*" "\"server_listener_resource_name_" "template\" field is not a string.*")); if (GetParam().parse_xds_certificate_providers()) { - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "\"certificate_providers\" field is not an object")); } @@ -301,9 +301,9 @@ TEST_P(XdsBootstrapTest, XdsServerMissingServerUri) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); XdsBootstrap bootstrap(std::move(json), &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex("errors parsing \"xds_servers\" array.*" "errors parsing index 0.*" "\"server_uri\" field not present")); @@ -322,10 +322,10 @@ TEST_P(XdsBootstrapTest, XdsServerUriAndCredsWrongTypes) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); XdsBootstrap bootstrap(std::move(json), &error); EXPECT_THAT( - grpc_error_string(error), + grpc_error_std_string(error), ::testing::ContainsRegex("errors parsing \"xds_servers\" array.*" "errors parsing index 0.*" "\"server_uri\" field is not a string.*" @@ -350,10 +350,10 @@ TEST_P(XdsBootstrapTest, ChannelCredsFieldsWrongTypes) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); XdsBootstrap bootstrap(std::move(json), &error); EXPECT_THAT( - grpc_error_string(error), + grpc_error_std_string(error), ::testing::ContainsRegex("errors parsing \"xds_servers\" array.*" "errors parsing index 0.*" "errors parsing \"channel_creds\" array.*" @@ -375,9 +375,9 @@ TEST_P(XdsBootstrapTest, NodeFieldsWrongTypes) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); XdsBootstrap bootstrap(std::move(json), &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex("errors parsing \"node\" object.*" "\"id\" field is not a string.*" "\"cluster\" field is not a string.*" @@ -399,9 +399,9 @@ TEST_P(XdsBootstrapTest, LocalityFieldsWrongType) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); XdsBootstrap bootstrap(std::move(json), &error); - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex("errors parsing \"node\" object.*" "errors parsing \"locality\" object.*" "\"region\" field is not a string.*" @@ -425,15 +425,15 @@ TEST_P(XdsBootstrapTest, CertificateProvidersElementWrongType) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); XdsBootstrap bootstrap(std::move(json), &error); if (GetParam().parse_xds_certificate_providers()) { - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "errors parsing \"certificate_providers\" object.*" "element \"plugin\" is not an object")); } else { - EXPECT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + EXPECT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); } GRPC_ERROR_UNREF(error); } @@ -455,16 +455,16 @@ TEST_P(XdsBootstrapTest, CertificateProvidersPluginNameWrongType) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); XdsBootstrap bootstrap(std::move(json), &error); if (GetParam().parse_xds_certificate_providers()) { - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "errors parsing \"certificate_providers\" object.*" "errors parsing element \"plugin\".*" "\"plugin_name\" field is not a string")); } else { - EXPECT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + EXPECT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); } GRPC_ERROR_UNREF(error); } @@ -540,16 +540,16 @@ TEST_P(XdsBootstrapTest, CertificateProvidersFakePluginParsingError) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); XdsBootstrap bootstrap(std::move(json), &error); if (GetParam().parse_xds_certificate_providers()) { - EXPECT_THAT(grpc_error_string(error), + EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "errors parsing \"certificate_providers\" object.*" "errors parsing element \"fake_plugin\".*" "field:config field:value not of type number")); } else { - EXPECT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + EXPECT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); } GRPC_ERROR_UNREF(error); } @@ -576,9 +576,9 @@ TEST_P(XdsBootstrapTest, CertificateProvidersFakePluginParsingSuccess) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); XdsBootstrap bootstrap(std::move(json), &error); - ASSERT_TRUE(error == GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_TRUE(error == GRPC_ERROR_NONE) << grpc_error_std_string(error); if (GetParam().parse_xds_certificate_providers()) { const CertificateProviderStore::PluginDefinition& fake_plugin = bootstrap.certificate_providers().at("fake_plugin"); @@ -613,9 +613,9 @@ TEST_P(XdsBootstrapTest, CertificateProvidersFakePluginEmptyConfig) { "}"; grpc_error_handle error = GRPC_ERROR_NONE; Json json = Json::Parse(json_str, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); XdsBootstrap bootstrap(std::move(json), &error); - ASSERT_TRUE(error == GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_TRUE(error == GRPC_ERROR_NONE) << grpc_error_std_string(error); if (GetParam().parse_xds_certificate_providers()) { const CertificateProviderStore::PluginDefinition& fake_plugin = bootstrap.certificate_providers().at("fake_plugin"); diff --git a/test/core/xds/xds_certificate_provider_test.cc b/test/core/xds/xds_certificate_provider_test.cc index 0ce748cf3fd..32e2bcb1697 100644 --- a/test/core/xds/xds_certificate_provider_test.cc +++ b/test/core/xds/xds_certificate_provider_test.cc @@ -149,16 +149,16 @@ TEST( GRPC_ERROR_CREATE_FROM_STATIC_STRING(kIdentityErrorMessage)); EXPECT_EQ(watcher->root_certs(), kRootCert2); EXPECT_EQ(watcher->key_cert_pairs(), MakeKeyCertPairsType2()); - EXPECT_THAT(grpc_error_string(watcher->root_cert_error()), + EXPECT_THAT(grpc_error_std_string(watcher->root_cert_error()), ::testing::HasSubstr(kRootErrorMessage)); - EXPECT_THAT(grpc_error_string(watcher->identity_cert_error()), + EXPECT_THAT(grpc_error_std_string(watcher->identity_cert_error()), ::testing::HasSubstr(kIdentityErrorMessage)); // Send an update for root certs. Test that the root cert error is reset. root_cert_distributor->SetKeyMaterials("root", kRootCert1, absl::nullopt); EXPECT_EQ(watcher->root_certs(), kRootCert1); EXPECT_EQ(watcher->key_cert_pairs(), MakeKeyCertPairsType2()); EXPECT_EQ(watcher->root_cert_error(), GRPC_ERROR_NONE); - EXPECT_THAT(grpc_error_string(watcher->identity_cert_error()), + EXPECT_THAT(grpc_error_std_string(watcher->identity_cert_error()), ::testing::HasSubstr(kIdentityErrorMessage)); // Send an update for identity certs. Test that the identity cert error is // reset. @@ -217,16 +217,16 @@ TEST(XdsCertificateProviderTest, GRPC_ERROR_CREATE_FROM_STATIC_STRING(kIdentityErrorMessage)); EXPECT_EQ(watcher->root_certs(), kRootCert2); EXPECT_EQ(watcher->key_cert_pairs(), MakeKeyCertPairsType2()); - EXPECT_THAT(grpc_error_string(watcher->root_cert_error()), + EXPECT_THAT(grpc_error_std_string(watcher->root_cert_error()), ::testing::HasSubstr(kRootErrorMessage)); - EXPECT_THAT(grpc_error_string(watcher->identity_cert_error()), + EXPECT_THAT(grpc_error_std_string(watcher->identity_cert_error()), ::testing::HasSubstr(kIdentityErrorMessage)); // Send an update for root certs. Test that the root cert error is reset. root_cert_distributor->SetKeyMaterials("test", kRootCert1, absl::nullopt); EXPECT_EQ(watcher->root_certs(), kRootCert1); EXPECT_EQ(watcher->key_cert_pairs(), MakeKeyCertPairsType2()); EXPECT_EQ(watcher->root_cert_error(), GRPC_ERROR_NONE); - EXPECT_THAT(grpc_error_string(watcher->identity_cert_error()), + EXPECT_THAT(grpc_error_std_string(watcher->identity_cert_error()), ::testing::HasSubstr(kIdentityErrorMessage)); // Send an update for identity certs. Test that the identity cert error is // reset. @@ -281,7 +281,7 @@ TEST(XdsCertificateProviderTest, GRPC_ERROR_CREATE_FROM_STATIC_STRING(kRootErrorMessage)); EXPECT_EQ(watcher->root_certs(), kRootCert2); EXPECT_EQ(watcher->key_cert_pairs(), MakeKeyCertPairsType2()); - EXPECT_THAT(grpc_error_string(watcher->root_cert_error()), + EXPECT_THAT(grpc_error_std_string(watcher->root_cert_error()), ::testing::HasSubstr(kRootErrorMessage)); EXPECT_EQ(watcher->identity_cert_error(), GRPC_ERROR_NONE); distributor->SetErrorForCert( @@ -289,16 +289,16 @@ TEST(XdsCertificateProviderTest, GRPC_ERROR_CREATE_FROM_STATIC_STRING(kIdentityErrorMessage)); EXPECT_EQ(watcher->root_certs(), kRootCert2); EXPECT_EQ(watcher->key_cert_pairs(), MakeKeyCertPairsType2()); - EXPECT_THAT(grpc_error_string(watcher->root_cert_error()), + EXPECT_THAT(grpc_error_std_string(watcher->root_cert_error()), ::testing::HasSubstr(kRootErrorMessage)); - EXPECT_THAT(grpc_error_string(watcher->identity_cert_error()), + EXPECT_THAT(grpc_error_std_string(watcher->identity_cert_error()), ::testing::HasSubstr(kIdentityErrorMessage)); // Send an update for root distributor->SetKeyMaterials("root", kRootCert1, MakeKeyCertPairsType1()); EXPECT_EQ(watcher->root_certs(), kRootCert1); EXPECT_EQ(watcher->key_cert_pairs(), MakeKeyCertPairsType2()); EXPECT_EQ(watcher->root_cert_error(), GRPC_ERROR_NONE); - EXPECT_THAT(grpc_error_string(watcher->identity_cert_error()), + EXPECT_THAT(grpc_error_std_string(watcher->identity_cert_error()), ::testing::HasSubstr(kIdentityErrorMessage)); // Send an update for identity distributor->SetKeyMaterials("identity", kRootCert2, MakeKeyCertPairsType1()); @@ -345,7 +345,7 @@ TEST(XdsCertificateProviderTest, absl::nullopt); EXPECT_EQ(watcher->root_certs(), kRootCert2); EXPECT_EQ(watcher->key_cert_pairs(), MakeKeyCertPairsType2()); - EXPECT_THAT(grpc_error_string(watcher->root_cert_error()), + EXPECT_THAT(grpc_error_std_string(watcher->root_cert_error()), ::testing::HasSubstr(kRootErrorMessage)); EXPECT_EQ(watcher->identity_cert_error(), GRPC_ERROR_NONE); // Set error for identity @@ -354,16 +354,16 @@ TEST(XdsCertificateProviderTest, GRPC_ERROR_CREATE_FROM_STATIC_STRING(kIdentityErrorMessage)); EXPECT_EQ(watcher->root_certs(), kRootCert2); EXPECT_EQ(watcher->key_cert_pairs(), MakeKeyCertPairsType2()); - EXPECT_THAT(grpc_error_string(watcher->root_cert_error()), + EXPECT_THAT(grpc_error_std_string(watcher->root_cert_error()), ::testing::HasSubstr(kRootErrorMessage)); - EXPECT_THAT(grpc_error_string(watcher->identity_cert_error()), + EXPECT_THAT(grpc_error_std_string(watcher->identity_cert_error()), ::testing::HasSubstr(kIdentityErrorMessage)); // Send an update for root distributor->SetKeyMaterials("", kRootCert1, absl::nullopt); EXPECT_EQ(watcher->root_certs(), kRootCert1); EXPECT_EQ(watcher->key_cert_pairs(), MakeKeyCertPairsType2()); EXPECT_EQ(watcher->root_cert_error(), GRPC_ERROR_NONE); - EXPECT_THAT(grpc_error_string(watcher->identity_cert_error()), + EXPECT_THAT(grpc_error_std_string(watcher->identity_cert_error()), ::testing::HasSubstr(kIdentityErrorMessage)); // Send an update for identity distributor->SetKeyMaterials("", absl::nullopt, MakeKeyCertPairsType1()); @@ -383,11 +383,11 @@ TEST(XdsCertificateProviderTest, SwapOutDistributorsMultipleTimes) { // Initially there are no certificate providers. EXPECT_EQ(watcher->root_certs(), absl::nullopt); EXPECT_EQ(watcher->key_cert_pairs(), absl::nullopt); - EXPECT_THAT(grpc_error_string(watcher->root_cert_error()), + EXPECT_THAT(grpc_error_std_string(watcher->root_cert_error()), ::testing::HasSubstr( "No certificate provider available for root certificates")); EXPECT_THAT( - grpc_error_string(watcher->identity_cert_error()), + grpc_error_std_string(watcher->identity_cert_error()), ::testing::HasSubstr( "No certificate provider available for identity certificates")); // Update root cert distributor. @@ -396,7 +396,7 @@ TEST(XdsCertificateProviderTest, SwapOutDistributorsMultipleTimes) { EXPECT_EQ(watcher->key_cert_pairs(), absl::nullopt); EXPECT_EQ(watcher->root_cert_error(), GRPC_ERROR_NONE); EXPECT_THAT( - grpc_error_string(watcher->identity_cert_error()), + grpc_error_std_string(watcher->identity_cert_error()), ::testing::HasSubstr( "No certificate provider available for identity certificates")); // Update identity cert distributor @@ -417,9 +417,9 @@ TEST(XdsCertificateProviderTest, SwapOutDistributorsMultipleTimes) { GRPC_ERROR_CREATE_FROM_STATIC_STRING(kIdentityErrorMessage)); EXPECT_EQ(watcher->root_certs(), kRootCert2); EXPECT_EQ(watcher->key_cert_pairs(), MakeKeyCertPairsType2()); - EXPECT_THAT(grpc_error_string(watcher->root_cert_error()), + EXPECT_THAT(grpc_error_std_string(watcher->root_cert_error()), ::testing::HasSubstr(kRootErrorMessage)); - EXPECT_THAT(grpc_error_string(watcher->identity_cert_error()), + EXPECT_THAT(grpc_error_std_string(watcher->identity_cert_error()), ::testing::HasSubstr(kIdentityErrorMessage)); // Send an update again distributor->SetKeyMaterials("", kRootCert1, MakeKeyCertPairsType1()); @@ -432,7 +432,7 @@ TEST(XdsCertificateProviderTest, SwapOutDistributorsMultipleTimes) { distributor->SetKeyMaterials("", kRootCert2, MakeKeyCertPairsType2()); EXPECT_EQ(watcher->root_certs(), kRootCert1); // not updated EXPECT_EQ(watcher->key_cert_pairs(), MakeKeyCertPairsType2()); - EXPECT_THAT(grpc_error_string(watcher->root_cert_error()), + EXPECT_THAT(grpc_error_std_string(watcher->root_cert_error()), ::testing::HasSubstr( "No certificate provider available for root certificates")); EXPECT_EQ(watcher->identity_cert_error(), GRPC_ERROR_NONE); @@ -441,11 +441,11 @@ TEST(XdsCertificateProviderTest, SwapOutDistributorsMultipleTimes) { distributor->SetKeyMaterials("", kRootCert1, MakeKeyCertPairsType1()); EXPECT_EQ(watcher->root_certs(), kRootCert1); EXPECT_EQ(watcher->key_cert_pairs(), MakeKeyCertPairsType2()); // not updated - EXPECT_THAT(grpc_error_string(watcher->root_cert_error()), + EXPECT_THAT(grpc_error_std_string(watcher->root_cert_error()), ::testing::HasSubstr( "No certificate provider available for root certificates")); EXPECT_THAT( - grpc_error_string(watcher->identity_cert_error()), + grpc_error_std_string(watcher->identity_cert_error()), ::testing::HasSubstr( "No certificate provider available for identity certificates")); // Change certificate names being watched, without any certificate updates. @@ -453,11 +453,11 @@ TEST(XdsCertificateProviderTest, SwapOutDistributorsMultipleTimes) { provider.UpdateIdentityCertNameAndDistributor("", "identity", distributor); EXPECT_EQ(watcher->root_certs(), kRootCert1); EXPECT_EQ(watcher->key_cert_pairs(), MakeKeyCertPairsType2()); - EXPECT_THAT(grpc_error_string(watcher->root_cert_error()), + EXPECT_THAT(grpc_error_std_string(watcher->root_cert_error()), ::testing::HasSubstr( "No certificate provider available for root certificates")); EXPECT_THAT( - grpc_error_string(watcher->identity_cert_error()), + grpc_error_std_string(watcher->identity_cert_error()), ::testing::HasSubstr( "No certificate provider available for identity certificates")); // Send out certificate updates. @@ -509,11 +509,11 @@ TEST(XdsCertificateProviderTest, MultipleCertNames) { std::unique_ptr(watcher1), "test1", "test1"); EXPECT_EQ(watcher1->root_certs(), absl::nullopt); EXPECT_EQ(watcher1->key_cert_pairs(), absl::nullopt); - EXPECT_THAT(grpc_error_string(watcher1->root_cert_error()), + EXPECT_THAT(grpc_error_std_string(watcher1->root_cert_error()), ::testing::HasSubstr( "No certificate provider available for root certificates")); EXPECT_THAT( - grpc_error_string(watcher1->identity_cert_error()), + grpc_error_std_string(watcher1->identity_cert_error()), ::testing::HasSubstr( "No certificate provider available for identity certificates")); // Add distributor for "test1". This will return data to the watcher. @@ -557,11 +557,11 @@ TEST(XdsCertificateProviderTest, UnknownCertName) { auto* watcher = new TestCertificatesWatcher; provider.distributor()->WatchTlsCertificates( std::unique_ptr(watcher), "test", "test"); - EXPECT_THAT(grpc_error_string(watcher->root_cert_error()), + EXPECT_THAT(grpc_error_std_string(watcher->root_cert_error()), ::testing::HasSubstr( "No certificate provider available for root certificates")); EXPECT_THAT( - grpc_error_string(watcher->identity_cert_error()), + grpc_error_std_string(watcher->identity_cert_error()), ::testing::HasSubstr( "No certificate provider available for identity certificates")); } diff --git a/test/cpp/client/destroy_grpclb_channel_with_active_connect_stress_test.cc b/test/cpp/client/destroy_grpclb_channel_with_active_connect_stress_test.cc index 5bbb29bc546..c514d8e8a83 100644 --- a/test/cpp/client/destroy_grpclb_channel_with_active_connect_stress_test.cc +++ b/test/cpp/client/destroy_grpclb_channel_with_active_connect_stress_test.cc @@ -71,7 +71,7 @@ void TryConnectAndDestroy() { grpc_error_handle error = GRPC_ERROR_NONE; lb_address_result.service_config = grpc_core::ServiceConfig::Create( nullptr, "{\"loadBalancingConfig\":[{\"grpclb\":{}}]}", &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); grpc_arg arg = grpc_core::CreateGrpclbBalancerAddressesArg(&addresses); lb_address_result.args = grpc_channel_args_copy_and_add(nullptr, &arg, 1); response_generator->SetResponse(lb_address_result); diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index 5406c7ddac5..e35125380d5 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -2046,7 +2046,7 @@ class XdsEnd2endTest : public ::testing::TestWithParam { : kDefaultServiceConfigWithoutLoadReporting; result.service_config = grpc_core::ServiceConfig::Create(nullptr, service_config_json, &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); ASSERT_NE(result.service_config.get(), nullptr); if (response_generator == nullptr) { response_generator = response_generator_.get(); @@ -2078,7 +2078,7 @@ class XdsEnd2endTest : public ::testing::TestWithParam { result.service_config = grpc_core::ServiceConfig::Create( nullptr, service_config_json, &error); ASSERT_NE(result.service_config.get(), nullptr); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); } if (expected_targets != nullptr) { grpc_arg expected_targets_arg = grpc_channel_arg_string_create( diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc index 9f03222bd7f..bc33741a3e9 100644 --- a/test/cpp/naming/resolver_component_test.cc +++ b/test/cpp/naming/resolver_component_test.cc @@ -269,7 +269,7 @@ void CheckServiceConfigResultLocked(const char* service_config_json, if (args->expected_service_config_error.empty()) { EXPECT_EQ(service_config_error, GRPC_ERROR_NONE); } else { - EXPECT_THAT(grpc_error_string(service_config_error), + EXPECT_THAT(grpc_error_std_string(service_config_error), testing::HasSubstr(args->expected_service_config_error)); } GRPC_ERROR_UNREF(service_config_error); @@ -436,7 +436,8 @@ class ResultHandler : public grpc_core::Resolver::ResultHandler { } void ReturnError(grpc_error_handle error) override { - gpr_log(GPR_ERROR, "resolver returned error: %s", grpc_error_string(error)); + gpr_log(GPR_ERROR, "resolver returned error: %s", + grpc_error_std_string(error).c_str()); GPR_ASSERT(false); } diff --git a/test/cpp/util/channel_trace_proto_helper.cc b/test/cpp/util/channel_trace_proto_helper.cc index 88b3bd15125..2e1c7bee04c 100644 --- a/test/cpp/util/channel_trace_proto_helper.cc +++ b/test/cpp/util/channel_trace_proto_helper.cc @@ -61,7 +61,7 @@ void VaidateProtoJsonTranslation(const std::string& json_str) { grpc_error_handle error = GRPC_ERROR_NONE; grpc_core::Json parsed_json = grpc_core::Json::Parse(proto_json_str.c_str(), &error); - ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); + ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); ASSERT_EQ(parsed_json.type(), grpc_core::Json::Type::OBJECT); proto_json_str = parsed_json.Dump(); // uncomment these to compare the json strings.