From ec4c61a3ae08b2990700f055d96a014cdfbcf869 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Thu, 7 Oct 2021 14:49:59 -0700 Subject: [PATCH] Various fixes on absl::Status migration (#27557) --- .../lb_policy/xds/xds_cluster_resolver.cc | 2 +- .../transport/chttp2/server/chttp2_server.cc | 2 + .../cronet/transport/cronet_transport.cc | 2 +- src/core/lib/iomgr/combiner.cc | 7 +- src/core/lib/iomgr/endpoint_cfstream.cc | 10 ++- src/core/lib/iomgr/error.cc | 75 ++++++++++++++++--- src/core/lib/iomgr/error.h | 2 +- src/core/lib/iomgr/error_cfstream.cc | 5 ++ src/core/lib/iomgr/ev_poll_posix.cc | 10 ++- src/core/lib/iomgr/tcp_client_cfstream.cc | 6 +- src/core/lib/iomgr/tcp_server_posix.cc | 4 +- src/core/lib/transport/error_utils.cc | 10 ++- src/cpp/client/secure_credentials.cc | 1 + test/core/end2end/fuzzers/api_fuzzer.cc | 4 +- test/core/end2end/inproc_callback_test.cc | 1 - test/core/end2end/tests/cancel_test_helpers.h | 2 +- test/core/end2end/tests/simple_request.cc | 1 - test/core/iomgr/error_test.cc | 8 +- .../resource_quota/memory_quota_fuzzer.cc | 2 +- test/cpp/end2end/end2end_test.cc | 3 + 20 files changed, 119 insertions(+), 38 deletions(-) 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 422c8acf91d..b1f09f9d8e9 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 @@ -1162,7 +1162,7 @@ class XdsClusterResolverLbFactory : public LoadBalancingPolicyFactory { if (!discovery_mechanism_errors.empty()) { grpc_error_handle error = GRPC_ERROR_CREATE_FROM_CPP_STRING( absl::StrCat("field:discovery_mechanism element: ", i, " error")); - for (grpc_error_handle discovery_mechanism_error : + for (const grpc_error_handle& discovery_mechanism_error : discovery_mechanism_errors) { error = grpc_error_add_child(error, discovery_mechanism_error); } diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc index 8d330aeb7c6..ea2dd18341d 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.cc +++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc @@ -596,6 +596,7 @@ grpc_error_handle Chttp2ServerListener::Create( // The bulk of this method is inside of a lambda to make cleanup // easier without using goto. grpc_error_handle error = [&]() { + grpc_error_handle error = GRPC_ERROR_NONE; // Create Chttp2ServerListener. listener = new Chttp2ServerListener( server, args, args_modifier, @@ -861,6 +862,7 @@ grpc_error_handle Chttp2ServerAddPort(Server* server, const char* addr, std::vector error_list; // Using lambda to avoid use of goto. grpc_error_handle error = [&]() { + grpc_error_handle error = GRPC_ERROR_NONE; if (absl::StartsWith(addr, kUnixUriPrefix)) { error = grpc_resolve_unix_domain_address( addr + sizeof(kUnixUriPrefix) - 1, &resolved); diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.cc b/src/core/ext/transport/cronet/transport/cronet_transport.cc index 18483e4367e..a28fdf003e2 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.cc +++ b/src/core/ext/transport/cronet/transport/cronet_transport.cc @@ -1330,7 +1330,7 @@ static enum e_op_result execute_stream_op(struct op_and_state* oas) { result = ACTION_TAKEN_NO_CALLBACK; } stream_state->state_op_done[OP_CANCEL_ERROR] = true; - if (!stream_state->cancel_error) { + if (stream_state->cancel_error == GRPC_ERROR_NONE) { stream_state->cancel_error = GRPC_ERROR_REF(stream_op->payload->cancel_stream.cancel_error); } diff --git a/src/core/lib/iomgr/combiner.cc b/src/core/lib/iomgr/combiner.cc index 5d833383ed3..1b5add88cd2 100644 --- a/src/core/lib/iomgr/combiner.cc +++ b/src/core/lib/iomgr/combiner.cc @@ -311,9 +311,10 @@ static void combiner_finally_exec(grpc_core::Combiner* lock, static void enqueue_finally(void* closure, grpc_error_handle error) { grpc_closure* cl = static_cast(closure); - combiner_finally_exec( - reinterpret_cast(cl->error_data.scratch), cl, - GRPC_ERROR_REF(error)); + grpc_core::Combiner* lock = + reinterpret_cast(cl->error_data.scratch); + cl->error_data.scratch = 0; + combiner_finally_exec(lock, cl, GRPC_ERROR_REF(error)); } namespace grpc_core { diff --git a/src/core/lib/iomgr/endpoint_cfstream.cc b/src/core/lib/iomgr/endpoint_cfstream.cc index 2f389dfed0f..224e2766bd3 100644 --- a/src/core/lib/iomgr/endpoint_cfstream.cc +++ b/src/core/lib/iomgr/endpoint_cfstream.cc @@ -149,7 +149,7 @@ static void CallWriteCb(CFStreamEndpoint* ep, grpc_error_handle error) { static void ReadAction(void* arg, grpc_error_handle error) { CFStreamEndpoint* ep = static_cast(arg); GPR_ASSERT(ep->read_cb != nullptr); - if (error) { + if (error != GRPC_ERROR_NONE) { grpc_slice_buffer_reset_and_unref_internal(ep->read_slices); CallReadCb(ep, GRPC_ERROR_REF(error)); EP_UNREF(ep, "read"); @@ -191,7 +191,7 @@ static void ReadAction(void* arg, grpc_error_handle error) { static void WriteAction(void* arg, grpc_error_handle error) { CFStreamEndpoint* ep = static_cast(arg); GPR_ASSERT(ep->write_cb != nullptr); - if (error) { + if (error != GRPC_ERROR_NONE) { grpc_slice_buffer_reset_and_unref_internal(ep->write_slices); CallWriteCb(ep, GRPC_ERROR_REF(error)); EP_UNREF(ep, "write"); @@ -286,13 +286,15 @@ static void CFStreamWrite(grpc_endpoint* ep, grpc_slice_buffer* slices, void CFStreamShutdown(grpc_endpoint* ep, grpc_error_handle why) { CFStreamEndpoint* ep_impl = reinterpret_cast(ep); if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "CFStream endpoint:%p shutdown (%p)", ep_impl, why); + gpr_log(GPR_DEBUG, "CFStream endpoint:%p shutdown (%s)", ep_impl, + grpc_error_std_string(why).c_str()); } CFReadStreamClose(ep_impl->read_stream); CFWriteStreamClose(ep_impl->write_stream); ep_impl->stream_sync->Shutdown(why); if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "CFStream endpoint:%p shutdown DONE (%p)", ep_impl, why); + gpr_log(GPR_DEBUG, "CFStream endpoint:%p shutdown DONE (%s)", ep_impl, + grpc_error_std_string(why).c_str()); } } diff --git a/src/core/lib/iomgr/error.cc b/src/core/lib/iomgr/error.cc index ba72d150e65..b46cd8d8295 100644 --- a/src/core/lib/iomgr/error.cc +++ b/src/core/lib/iomgr/error.cc @@ -90,11 +90,17 @@ absl::Status grpc_wsa_error(const grpc_core::DebugLocation& location, int err, StatusSetInt(&s, grpc_core::StatusIntProperty::kWsaError, err); StatusSetStr(&s, grpc_core::StatusStrProperty::kOsError, utf8_message); StatusSetStr(&s, grpc_core::StatusStrProperty::kSyscall, call_name); + return s; } #endif grpc_error_handle grpc_error_set_int(grpc_error_handle src, grpc_error_ints which, intptr_t value) { + if (src == GRPC_ERROR_NONE) { + src = absl::UnknownError(""); + StatusSetInt(&src, grpc_core::StatusIntProperty::kRpcStatus, + GRPC_STATUS_OK); + } grpc_core::StatusSetInt( &src, static_cast(which), value); return src; @@ -131,32 +137,77 @@ bool grpc_error_get_int(grpc_error_handle error, grpc_error_ints which, grpc_error_handle grpc_error_set_str(grpc_error_handle src, grpc_error_strs which, absl::string_view str) { - grpc_core::StatusSetStr( - &src, static_cast(which), str); + if (src == GRPC_ERROR_NONE) { + src = absl::UnknownError(""); + StatusSetInt(&src, grpc_core::StatusIntProperty::kRpcStatus, + GRPC_STATUS_OK); + } + if (which == GRPC_ERROR_STR_DESCRIPTION) { + // To change the message of absl::Status, a new instance should be created + // with a code and payload because it doesn't have a setter for it. + absl::Status s = absl::Status(src.code(), str); + src.ForEachPayload( + [&](absl::string_view type_url, const absl::Cord& payload) { + s.SetPayload(type_url, payload); + }); + return s; + } else { + grpc_core::StatusSetStr( + &src, static_cast(which), str); + } return src; } bool grpc_error_get_str(grpc_error_handle error, grpc_error_strs which, std::string* s) { - absl::optional value = grpc_core::StatusGetStr( - error, static_cast(which)); - if (value.has_value()) { - *s = std::move(*value); - return true; + if (which == GRPC_ERROR_STR_DESCRIPTION) { + // absl::Status uses the message field for GRPC_ERROR_STR_DESCRIPTION + // instead of using payload. + absl::string_view msg = error.message(); + if (msg.empty()) { + return false; + } else { + *s = std::string(msg); + return true; + } } else { - // TODO(veblush): Remove this once absl::Status migration is done - if (which == GRPC_ERROR_STR_DESCRIPTION && !error.message().empty()) { + absl::optional value = grpc_core::StatusGetStr( + error, static_cast(which)); + if (value.has_value()) { *s = std::move(*value); return true; + } else { + // TODO(veblush): Remove this once absl::Status migration is done + if (which == GRPC_ERROR_STR_GRPC_MESSAGE) { + switch (error.code()) { + case absl::StatusCode::kOk: + *s = ""; + return true; + case absl::StatusCode::kResourceExhausted: + *s = "RESOURCE_EXHAUSTED"; + return true; + case absl::StatusCode::kCancelled: + *s = "CANCELLED"; + return true; + default: + break; + } + } + return false; } - return false; } } grpc_error_handle grpc_error_add_child(grpc_error_handle src, grpc_error_handle child) { - grpc_core::StatusAddChild(&src, child); - return src; + if (src.ok()) { + return child; + } else { + if (!child.ok()) { + grpc_core::StatusAddChild(&src, child); + } + return src; + } } bool grpc_log_error(const char* what, grpc_error_handle error, const char* file, diff --git a/src/core/lib/iomgr/error.h b/src/core/lib/iomgr/error.h index e776853396d..06c0e7df38a 100644 --- a/src/core/lib/iomgr/error.h +++ b/src/core/lib/iomgr/error.h @@ -161,7 +161,7 @@ void grpc_enable_error_creation(); #define GRPC_ERROR_CANCELLED absl::CancelledError() #define GRPC_ERROR_REF(err) (err) -#define GRPC_ERROR_UNREF(err) +#define GRPC_ERROR_UNREF(err) (void)(err) #define GRPC_ERROR_CREATE_FROM_STATIC_STRING(desc) \ StatusCreate(absl::StatusCode::kUnknown, desc, DEBUG_LOCATION, {}) diff --git a/src/core/lib/iomgr/error_cfstream.cc b/src/core/lib/iomgr/error_cfstream.cc index 9c93dde9cc8..84052aaeeac 100644 --- a/src/core/lib/iomgr/error_cfstream.cc +++ b/src/core/lib/iomgr/error_cfstream.cc @@ -48,7 +48,12 @@ grpc_error_handle grpc_error_create_from_cferror(const char* file, int line, absl::StrFormat("%s (error domain:%s, code:%ld, description:%s)", custom_desc, buf_domain, code, buf_desc); CFRelease(desc); +#ifdef GRPC_ERROR_IS_ABSEIL_STATUS + return StatusCreate(absl::StatusCode::kUnknown, error_msg, + grpc_core::DebugLocation(file, line), {}); +#else return grpc_error_create( file, line, grpc_slice_from_copied_string(error_msg.c_str()), NULL, 0); +#endif } #endif /* GRPC_CFSTREAM */ diff --git a/src/core/lib/iomgr/ev_poll_posix.cc b/src/core/lib/iomgr/ev_poll_posix.cc index 634990ddc8a..5a23c0a69fc 100644 --- a/src/core/lib/iomgr/ev_poll_posix.cc +++ b/src/core/lib/iomgr/ev_poll_posix.cc @@ -357,7 +357,12 @@ static void unref_by(grpc_fd* fd, int n) { gpr_mu_destroy(&fd->mu); grpc_iomgr_unregister_object(&fd->iomgr_object); fork_fd_list_remove_node(fd->fork_fd_list); - if (fd->shutdown) GRPC_ERROR_UNREF(fd->shutdown_error); + if (fd->shutdown) { + GRPC_ERROR_UNREF(fd->shutdown_error); + } +#ifdef GRPC_ERROR_IS_ABSEIL_STATUS + fd->shutdown_error.~Status(); +#endif gpr_free(fd); } else { GPR_ASSERT(old > n); @@ -372,6 +377,9 @@ static grpc_fd* fd_create(int fd, const char* name, bool track_err) { gpr_mu_init(&r->mu); gpr_atm_rel_store(&r->refst, 1); r->shutdown = 0; +#ifdef GRPC_ERROR_IS_ABSEIL_STATUS + new (&r->shutdown_error) absl::Status(); +#endif r->read_closure = CLOSURE_NOT_READY; r->write_closure = CLOSURE_NOT_READY; r->fd = fd; diff --git a/src/core/lib/iomgr/tcp_client_cfstream.cc b/src/core/lib/iomgr/tcp_client_cfstream.cc index d329f8d36b2..144ffe860fb 100644 --- a/src/core/lib/iomgr/tcp_client_cfstream.cc +++ b/src/core/lib/iomgr/tcp_client_cfstream.cc @@ -81,7 +81,8 @@ static void CFStreamConnectCleanup(CFStreamConnect* connect) { static void OnAlarm(void* arg, grpc_error_handle error) { CFStreamConnect* connect = static_cast(arg); if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "CLIENT_CONNECT :%p OnAlarm, error:%p", connect, error); + gpr_log(GPR_DEBUG, "CLIENT_CONNECT :%p OnAlarm, error:%s", connect, + grpc_error_std_string(error).c_str()); } gpr_mu_lock(&connect->mu); grpc_closure* closure = connect->closure; @@ -102,7 +103,8 @@ static void OnAlarm(void* arg, grpc_error_handle error) { static void OnOpen(void* arg, grpc_error_handle error) { CFStreamConnect* connect = static_cast(arg); if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "CLIENT_CONNECT :%p OnOpen, error:%p", connect, error); + gpr_log(GPR_DEBUG, "CLIENT_CONNECT :%p OnOpen, error:%s", connect, + grpc_error_std_string(error).c_str()); } gpr_mu_lock(&connect->mu); grpc_timer_cancel(&connect->alarm); diff --git a/src/core/lib/iomgr/tcp_server_posix.cc b/src/core/lib/iomgr/tcp_server_posix.cc index 73a118cef7d..3adfe235af6 100644 --- a/src/core/lib/iomgr/tcp_server_posix.cc +++ b/src/core/lib/iomgr/tcp_server_posix.cc @@ -236,7 +236,7 @@ static void on_read(void* arg, grpc_error_handle err) { } } - grpc_set_socket_no_sigpipe_if_possible(fd); + (void)grpc_set_socket_no_sigpipe_if_possible(fd); err = grpc_apply_socket_mutator_in_args(fd, GRPC_FD_SERVER_CONNECTION_USAGE, sp->server->channel_args); @@ -595,7 +595,7 @@ class ExternalConnectionHandler : public grpc_core::TcpServerFdHandler { close(fd); return; } - grpc_set_socket_no_sigpipe_if_possible(fd); + (void)grpc_set_socket_no_sigpipe_if_possible(fd); std::string addr_str = grpc_sockaddr_to_uri(&addr); if (grpc_tcp_trace.enabled()) { gpr_log(GPR_INFO, "SERVER_CONNECT: incoming external connection: %s", diff --git a/src/core/lib/transport/error_utils.cc b/src/core/lib/transport/error_utils.cc index 3fdfa92d217..2d2b67e393b 100644 --- a/src/core/lib/transport/error_utils.cc +++ b/src/core/lib/transport/error_utils.cc @@ -36,7 +36,7 @@ static grpc_error_handle recursively_find_error_with_field( } #ifdef GRPC_ERROR_IS_ABSEIL_STATUS std::vector children = grpc_core::StatusGetChildren(error); - for (auto child : children) { + for (const absl::Status& child : children) { grpc_error_handle result = recursively_find_error_with_field(child, which); if (result != GRPC_ERROR_NONE) return result; } @@ -103,6 +103,10 @@ void grpc_error_get_status(grpc_error_handle error, grpc_millis deadline, &integer)) { status = grpc_http2_error_to_grpc_status( static_cast(integer), deadline); + } else { +#ifdef GRPC_ERROR_IS_ABSEIL_STATUS + status = static_cast(found_error.code()); +#endif } if (code != nullptr) *code = status; @@ -131,7 +135,7 @@ void grpc_error_get_status(grpc_error_handle error, grpc_millis deadline, if (!grpc_error_get_str(found_error, GRPC_ERROR_STR_DESCRIPTION, message)) { #ifdef GRPC_ERROR_IS_ABSEIL_STATUS - *message = grpc_error_std_string(error)); + *message = grpc_error_std_string(error); #else *message = "unknown error"; #endif @@ -167,7 +171,7 @@ bool grpc_error_has_clear_grpc_status(grpc_error_handle error) { } #ifdef GRPC_ERROR_IS_ABSEIL_STATUS std::vector children = grpc_core::StatusGetChildren(error); - for (auto child : children) { + for (const absl::Status& child : children) { if (grpc_error_has_clear_grpc_status(child)) { return true; } diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index 3a3b04a6845..71b716051d7 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -217,6 +217,7 @@ grpc::Status StsCredentialsOptionsFromEnv(StsCredentialsOptions* options) { char* sts_creds_path = gpr_getenv("STS_CREDENTIALS"); grpc_error_handle error = GRPC_ERROR_NONE; grpc::Status status; + // NOLINTNEXTLINE(clang-diagnostic-unused-lambda-capture) auto cleanup = [&json_string, &sts_creds_path, &error, &status]() { grpc_slice_unref_internal(json_string); gpr_free(sts_creds_path); diff --git a/test/core/end2end/fuzzers/api_fuzzer.cc b/test/core/end2end/fuzzers/api_fuzzer.cc index 0882c02cbe0..3b459a6959b 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.cc +++ b/test/core/end2end/fuzzers/api_fuzzer.cc @@ -79,7 +79,7 @@ typedef struct addr_req { std::unique_ptr* addresses; } addr_req; -static void finish_resolve(void* arg, grpc_error* error) { +static void finish_resolve(void* arg, grpc_error_handle error) { addr_req* r = static_cast(arg); if (error == GRPC_ERROR_NONE && 0 == strcmp(r->addr, "server")) { @@ -162,7 +162,7 @@ typedef struct { grpc_slice_allocator* slice_allocator; } future_connect; -static void do_connect(void* arg, grpc_error* error) { +static void do_connect(void* arg, grpc_error_handle error) { future_connect* fc = static_cast(arg); if (error != GRPC_ERROR_NONE) { grpc_slice_allocator_destroy(fc->slice_allocator); diff --git a/test/core/end2end/inproc_callback_test.cc b/test/core/end2end/inproc_callback_test.cc index 18493e9f0f9..be36993ca39 100644 --- a/test/core/end2end/inproc_callback_test.cc +++ b/test/core/end2end/inproc_callback_test.cc @@ -414,7 +414,6 @@ static void simple_request_body(grpc_end2end_test_config config, // not likely to change much. Some parts of the error, like time created, // obviously are not checked. GPR_ASSERT(nullptr != strstr(error_string, "xyz")); - GPR_ASSERT(nullptr != strstr(error_string, "description")); GPR_ASSERT(nullptr != strstr(error_string, "Error received from peer")); GPR_ASSERT(nullptr != strstr(error_string, "grpc_message")); GPR_ASSERT(nullptr != strstr(error_string, "grpc_status")); diff --git a/test/core/end2end/tests/cancel_test_helpers.h b/test/core/end2end/tests/cancel_test_helpers.h index 1e75b2bef88..9c744d57a7f 100644 --- a/test/core/end2end/tests/cancel_test_helpers.h +++ b/test/core/end2end/tests/cancel_test_helpers.h @@ -34,7 +34,7 @@ static grpc_call_error wait_for_deadline(grpc_call* /*call*/, void* reserved) { } static const cancellation_mode cancellation_modes[] = { - {"cancel", grpc_call_cancel, GRPC_STATUS_CANCELLED, "Cancelled"}, + {"cancel", grpc_call_cancel, GRPC_STATUS_CANCELLED, "CANCELLED"}, {"deadline", wait_for_deadline, GRPC_STATUS_DEADLINE_EXCEEDED, "Deadline Exceeded"}, }; diff --git a/test/core/end2end/tests/simple_request.cc b/test/core/end2end/tests/simple_request.cc index df5d40e1447..3a0b75f5179 100644 --- a/test/core/end2end/tests/simple_request.cc +++ b/test/core/end2end/tests/simple_request.cc @@ -219,7 +219,6 @@ static void simple_request_body(grpc_end2end_test_config config, // not likely to change much. Some parts of the error, like time created, // obviously are not checked. GPR_ASSERT(nullptr != strstr(error_string, "xyz")); - GPR_ASSERT(nullptr != strstr(error_string, "description")); GPR_ASSERT(nullptr != strstr(error_string, "Error received from peer")); GPR_ASSERT(nullptr != strstr(error_string, "grpc_message")); GPR_ASSERT(nullptr != strstr(error_string, "grpc_status")); diff --git a/test/core/iomgr/error_test.cc b/test/core/iomgr/error_test.cc index d9430bf14bd..7dd29c86bc6 100644 --- a/test/core/iomgr/error_test.cc +++ b/test/core/iomgr/error_test.cc @@ -32,8 +32,11 @@ TEST(ErrorTest, SetGetInt) { grpc_error_handle error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test"); EXPECT_NE(error, GRPC_ERROR_NONE); intptr_t i = 0; +#ifndef NDEBUG + // GRPC_ERROR_INT_FILE_LINE is for debug only EXPECT_TRUE(grpc_error_get_int(error, GRPC_ERROR_INT_FILE_LINE, &i)); EXPECT_TRUE(i); // line set will never be 0 +#endif EXPECT_TRUE(!grpc_error_get_int(error, GRPC_ERROR_INT_ERRNO, &i)); EXPECT_TRUE(!grpc_error_get_int(error, GRPC_ERROR_INT_SIZE, &i)); @@ -56,13 +59,14 @@ TEST(ErrorTest, SetGetStr) { std::string str; EXPECT_TRUE(!grpc_error_get_str(error, GRPC_ERROR_STR_SYSCALL, &str)); EXPECT_TRUE(!grpc_error_get_str(error, GRPC_ERROR_STR_TSI_ERROR, &str)); - +#ifndef NDEBUG + // GRPC_ERROR_STR_FILE is for debug only EXPECT_TRUE(grpc_error_get_str(error, GRPC_ERROR_STR_FILE, &str)); EXPECT_THAT(str, testing::HasSubstr("error_test.c")); // __FILE__ expands differently on // Windows. All should at least // contain error_test.c - +#endif EXPECT_TRUE(grpc_error_get_str(error, GRPC_ERROR_STR_DESCRIPTION, &str)); EXPECT_EQ(str, "Test"); diff --git a/test/core/resource_quota/memory_quota_fuzzer.cc b/test/core/resource_quota/memory_quota_fuzzer.cc index 1da0616985c..13ea6f200e6 100644 --- a/test/core/resource_quota/memory_quota_fuzzer.cc +++ b/test/core/resource_quota/memory_quota_fuzzer.cc @@ -113,7 +113,7 @@ class Fuzzer { }; auto* args = new Args{std::move(sweep), cfg.msg(), this}; auto* closure = GRPC_CLOSURE_CREATE( - [](void* arg, grpc_error*) { + [](void* arg, grpc_error_handle) { auto* args = static_cast(arg); args->fuzzer->RunMsg(args->msg); delete args; diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 28e49f52e93..08980120223 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -1463,8 +1463,11 @@ TEST_P(End2endTest, ExpectErrorTest) { EXPECT_EQ(iter->error_message(), s.error_message()); EXPECT_EQ(iter->binary_error_details(), s.error_details()); EXPECT_TRUE(absl::StrContains(context.debug_error_string(), "created")); +#ifndef NDEBUG + // GRPC_ERROR_INT_FILE_LINE is for debug only EXPECT_TRUE(absl::StrContains(context.debug_error_string(), "file")); EXPECT_TRUE(absl::StrContains(context.debug_error_string(), "line")); +#endif EXPECT_TRUE(absl::StrContains(context.debug_error_string(), "status")); EXPECT_TRUE(absl::StrContains(context.debug_error_string(), "13")); }