Removed GRPC_ERROR_[INT|STR] macros (#31195)

* Clean-up which

* Reformat
pull/31222/head
Esun Kim 3 years ago committed by GitHub
parent 19babd6801
commit 347bf1a1f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      BUILD
  2. 5
      src/core/ext/filters/channel_idle/channel_idle_filter.cc
  3. 6
      src/core/ext/filters/client_channel/client_channel.cc
  4. 3
      src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
  5. 5
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
  6. 8
      src/core/ext/filters/client_channel/retry_filter.cc
  7. 3
      src/core/ext/filters/deadline/deadline_filter.cc
  8. 3
      src/core/ext/filters/http/message_compress/message_decompress_filter.cc
  9. 6
      src/core/ext/filters/message_size/message_size_filter.cc
  10. 3
      src/core/ext/filters/rbac/rbac_filter.cc
  11. 5
      src/core/ext/transport/binder/transport/binder_transport.cc
  12. 4
      src/core/ext/transport/chttp2/client/chttp2_connector.cc
  13. 66
      src/core/ext/transport/chttp2/transport/chttp2_transport.cc
  14. 3
      src/core/ext/transport/chttp2/transport/frame_data.cc
  15. 6
      src/core/ext/transport/chttp2/transport/frame_rst_stream.cc
  16. 7
      src/core/ext/transport/chttp2/transport/hpack_parser.cc
  17. 4
      src/core/ext/transport/chttp2/transport/parsing.cc
  18. 4
      src/core/ext/transport/cronet/transport/cronet_transport.cc
  19. 10
      src/core/ext/transport/inproc/inproc_transport.cc
  20. 15
      src/core/ext/xds/xds_server_config_fetcher.cc
  21. 9
      src/core/lib/channel/promise_based_filter.cc
  22. 2
      src/core/lib/gprpp/status_helper.h
  23. 3
      src/core/lib/http/httpcli.cc
  24. 4
      src/core/lib/iomgr/cfstream_handle.cc
  25. 4
      src/core/lib/iomgr/endpoint_cfstream.cc
  26. 37
      src/core/lib/iomgr/error.cc
  27. 48
      src/core/lib/iomgr/error.h
  28. 4
      src/core/lib/iomgr/ev_poll_posix.cc
  29. 4
      src/core/lib/iomgr/load_file.cc
  30. 2
      src/core/lib/iomgr/python_util.h
  31. 12
      src/core/lib/iomgr/resolve_address_posix.cc
  32. 3
      src/core/lib/iomgr/socket_utils_common_posix.cc
  33. 17
      src/core/lib/iomgr/tcp_client_posix.cc
  34. 2
      src/core/lib/iomgr/tcp_client_windows.cc
  35. 7
      src/core/lib/iomgr/tcp_posix.cc
  36. 2
      src/core/lib/iomgr/tcp_server_utils_posix_common.cc
  37. 4
      src/core/lib/iomgr/tcp_server_windows.cc
  38. 6
      src/core/lib/iomgr/tcp_windows.cc
  39. 4
      src/core/lib/security/credentials/google_default/google_default_credentials.cc
  40. 3
      src/core/lib/security/transport/server_auth_filter.cc
  41. 9
      src/core/lib/security/transport/tsi_error.cc
  42. 17
      src/core/lib/surface/call.cc
  43. 3
      src/core/lib/surface/server.cc
  44. 6
      src/core/lib/surface/validate_metadata.cc
  45. 39
      src/core/lib/transport/error_utils.cc
  46. 4
      src/core/lib/transport/error_utils.h
  47. 9
      src/core/lib/transport/transport.h
  48. 1
      src/cpp/ext/gcp/BUILD
  49. 6
      src/cpp/ext/gcp/observability_config.cc
  50. 3
      test/core/end2end/tests/filter_causes_close.cc
  51. 5
      test/core/end2end/tests/filter_init_fails.cc
  52. 4
      test/core/end2end/tests/retry_cancel_with_multiple_send_batches.cc
  53. 4
      test/core/end2end/tests/retry_recv_message_replay.cc
  54. 4
      test/core/end2end/tests/retry_recv_trailing_metadata_error.cc
  55. 4
      test/core/end2end/tests/retry_send_op_fails.cc
  56. 3
      test/core/end2end/tests/retry_transparent_goaway.cc
  57. 3
      test/core/end2end/tests/retry_transparent_not_sent_on_wire.cc
  58. 101
      test/core/iomgr/error_test.cc
  59. 6
      test/core/security/aws_request_signer_test.cc
  60. 16
      test/core/security/credentials_test.cc
  61. 4
      test/core/security/grpc_tls_certificate_distributor_test.cc
  62. 4
      test/core/security/grpc_tls_certificate_provider_test.cc
  63. 2
      test/core/security/tls_security_connector_test.cc
  64. 17
      test/core/transport/error_utils_test.cc
  65. 2
      test/cpp/end2end/end2end_test.cc

13
BUILD

@ -4014,6 +4014,7 @@ grpc_cc_library(
"slice_buffer",
"slice_refcount",
"sockaddr_utils",
"status_helper",
"subchannel_interface",
"time",
"transport_fwd",
@ -4144,6 +4145,7 @@ grpc_cc_library(
"ref_counted_ptr",
"single_set_ptr",
"sleep",
"status_helper",
"time",
"try_seq",
],
@ -4177,6 +4179,7 @@ grpc_cc_library(
"grpc_base",
"grpc_public_hdrs",
"iomgr_timer",
"status_helper",
"time",
],
)
@ -4243,6 +4246,7 @@ grpc_cc_library(
"json",
"service_config_parser",
"slice_buffer",
"status_helper",
],
)
@ -4319,6 +4323,7 @@ grpc_cc_library(
"json",
"json_util",
"service_config_parser",
"status_helper",
"transport_fwd",
],
)
@ -4371,6 +4376,7 @@ grpc_cc_library(
"seq",
"slice",
"slice_buffer",
"status_helper",
"transport_fwd",
],
)
@ -4870,6 +4876,7 @@ grpc_cc_library(
"resolved_address",
"slice_refcount",
"sockaddr_utils",
"status_helper",
"unique_type_name",
"uri_parser",
"xds_client",
@ -5703,6 +5710,7 @@ grpc_cc_library(
"server_address",
"slice",
"sockaddr_utils",
"status_helper",
"time",
"uri_parser",
],
@ -5926,6 +5934,7 @@ grpc_cc_library(
"slice",
"slice_refcount",
"sockaddr_utils",
"status_helper",
"tcp_connect_handshaker",
"time",
"uri_parser",
@ -6229,6 +6238,7 @@ grpc_cc_library(
"ref_counted_ptr",
"slice",
"slice_refcount",
"status_helper",
"time",
"unique_type_name",
"uri_parser",
@ -6579,6 +6589,7 @@ grpc_cc_library(
"seq",
"slice",
"slice_refcount",
"status_helper",
"try_seq",
"tsi_base",
"unique_type_name",
@ -7129,6 +7140,7 @@ grpc_cc_library(
"ref_counted_ptr",
"resolved_address",
"sockaddr_utils",
"status_helper",
"tcp_connect_handshaker",
"transport_fwd",
"unique_type_name",
@ -7210,6 +7222,7 @@ grpc_cc_library(
"ref_counted_ptr",
"slice",
"slice_buffer",
"status_helper",
"time",
"transport_fwd",
],

@ -38,6 +38,7 @@
#include "src/core/lib/event_engine/default_event_engine.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/orphanable.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/exec_ctx.h"
@ -187,7 +188,7 @@ void MaxAgeFilter::PostInit() {
grpc_transport_op* op = grpc_make_transport_op(nullptr);
op->goaway_error = grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("max_age"),
GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_NO_ERROR);
StatusIntProperty::kHttp2Error, GRPC_HTTP2_NO_ERROR);
grpc_channel_element* elem =
grpc_channel_stack_element(channel_stack, 0);
elem->filter->start_transport_op(elem, op);
@ -278,7 +279,7 @@ void ChannelIdleFilter::CloseChannel() {
auto* op = grpc_make_transport_op(nullptr);
op->disconnect_with_error = grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("enter idle"),
GRPC_ERROR_INT_CHANNEL_CONNECTIVITY_STATE, GRPC_CHANNEL_IDLE);
StatusIntProperty::ChannelConnectivityState, GRPC_CHANNEL_IDLE);
// Pass the transport op down to the channel stack.
auto* elem = grpc_channel_stack_element(channel_stack_, 0);
elem->filter->start_transport_op(elem, op);

@ -64,6 +64,7 @@
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/gprpp/work_serializer.h"
#include "src/core/lib/handshaker/proxy_mapper_registry.h"
@ -1700,7 +1701,8 @@ void ClientChannel::StartTransportOpLocked(grpc_transport_op* op) {
DestroyResolverAndLbPolicyLocked();
intptr_t value;
if (grpc_error_get_int(op->disconnect_with_error,
GRPC_ERROR_INT_CHANNEL_CONNECTIVITY_STATE, &value) &&
StatusIntProperty::ChannelConnectivityState,
&value) &&
static_cast<grpc_connectivity_state>(value) == GRPC_CHANNEL_IDLE) {
if (disconnect_error_.ok()) {
// Enter IDLE state.
@ -3177,7 +3179,7 @@ bool ClientChannel::LoadBalancedCall::PickSubchannelLocked(
*error = grpc_error_set_int(
absl_status_to_grpc_error(MaybeRewriteIllegalStatusCode(
std::move(drop_pick->status), "LB drop")),
GRPC_ERROR_INT_LB_POLICY_DROP, 1);
StatusIntProperty::kLbPolicyDrop, 1);
MaybeRemoveCallFromLbQueuedCallsLocked();
return true;
});

@ -46,6 +46,7 @@
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/gprpp/orphanable.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/gprpp/time.h"
#include "src/core/lib/iomgr/closure.h"
@ -433,7 +434,7 @@ AresClientChannelDNSResolver::AresRequestWrapper::OnResolvedLocked(
GRPC_CARES_TRACE_LOG("resolver:%p dns resolution failed: %s", this,
grpc_error_std_string(error).c_str());
std::string error_message;
grpc_error_get_str(error, GRPC_ERROR_STR_DESCRIPTION, &error_message);
grpc_error_get_str(error, StatusStrProperty::kDescription, &error_message);
absl::Status status = absl::UnavailableError(
absl::StrCat("DNS resolution failed for ", resolver_->name_to_resolve(),
": ", error_message));

@ -23,6 +23,7 @@
#include "absl/strings/string_view.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/sockaddr.h"
// IWYU pragma: no_include <arpa/nameser.h>
@ -872,13 +873,13 @@ grpc_error_handle grpc_dns_lookup_ares_continued(
if (host->empty()) {
error = grpc_error_set_str(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("unparseable host:port"),
GRPC_ERROR_STR_TARGET_ADDRESS, name);
grpc_core::StatusStrProperty::kTargetAddress, name);
return error;
} else if (check_port && port->empty()) {
if (default_port == nullptr || strlen(default_port) == 0) {
error = grpc_error_set_str(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("no port in name"),
GRPC_ERROR_STR_TARGET_ADDRESS, name);
grpc_core::StatusStrProperty::kTargetAddress, name);
return error;
}
*port = default_port;

@ -57,6 +57,7 @@
#include "src/core/lib/gprpp/orphanable.h"
#include "src/core/lib/gprpp/ref_counted.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/gprpp/time.h"
#include "src/core/lib/iomgr/call_combiner.h"
#include "src/core/lib/iomgr/closure.h"
@ -1282,7 +1283,8 @@ void RetryFilter::CallData::CallAttempt::OnPerAttemptRecvTimerLocked(
call_attempt->MaybeAddBatchForCancelOp(
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"retry perAttemptRecvTimeout exceeded"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_CANCELLED),
StatusIntProperty::kRpcStatus,
GRPC_STATUS_CANCELLED),
&closures);
// Check whether we should retry.
if (call_attempt->ShouldRetry(/*status=*/absl::nullopt,
@ -1597,7 +1599,7 @@ void GetCallStatus(
if (!error.ok()) {
grpc_error_get_status(error, deadline, status, nullptr, nullptr, nullptr);
intptr_t value = 0;
if (grpc_error_get_int(error, GRPC_ERROR_INT_LB_POLICY_DROP, &value) &&
if (grpc_error_get_int(error, StatusIntProperty::kLbPolicyDrop, &value) &&
value != 0) {
*is_lb_drop = true;
}
@ -1782,7 +1784,7 @@ void RetryFilter::CallData::CallAttempt::BatchData::RecvTrailingMetadataReady(
error.ok()
? grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("call attempt failed"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_CANCELLED)
StatusIntProperty::kRpcStatus, GRPC_STATUS_CANCELLED)
: error,
&closures);
// For transparent retries, add a closure to immediately start a new

@ -31,6 +31,7 @@
#include "src/core/lib/channel/channel_stack_builder.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/timer.h"
@ -85,7 +86,7 @@ class TimerState {
if (error != absl::CancelledError()) {
error = grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Deadline Exceeded"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_DEADLINE_EXCEEDED);
StatusIntProperty::kRpcStatus, GRPC_STATUS_DEADLINE_EXCEEDED);
deadline_state->call_combiner->Cancel(error);
GRPC_CLOSURE_INIT(&self->closure_, SendCancelOpInCallCombiner, self,
nullptr);

@ -38,6 +38,7 @@
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/compression/message_compress.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/call_combiner.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/error.h"
@ -179,7 +180,7 @@ void CallData::OnRecvMessageReady(void* arg, grpc_error_handle error) {
absl::StrFormat("Received message larger than max (%u vs. %d)",
(*calld->recv_message_)->Length(),
calld->max_recv_message_length_)),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_RESOURCE_EXHAUSTED);
StatusIntProperty::kRpcStatus, GRPC_STATUS_RESOURCE_EXHAUSTED);
return calld->ContinueRecvMessageReadyCallback(calld->error_);
}
SliceBuffer decompressed_slices;

@ -40,6 +40,7 @@
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/call_combiner.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/error.h"
@ -220,7 +221,8 @@ static void recv_message_ready(void* user_data, grpc_error_handle error) {
GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrFormat(
"Received message larger than max (%u vs. %d)",
(*calld->recv_message)->Length(), calld->limits.max_recv_size)),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_RESOURCE_EXHAUSTED);
grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_RESOURCE_EXHAUSTED);
error = grpc_error_add_child(error, new_error);
calld->error = error;
}
@ -276,7 +278,7 @@ static void message_size_start_transport_stream_op_batch(
"Sent message larger than max (%u vs. %d)",
op->payload->send_message.send_message->Length(),
calld->limits.max_send_size)),
GRPC_ERROR_INT_GRPC_STATUS,
grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_RESOURCE_EXHAUSTED),
calld->call_combiner);
return;

@ -30,6 +30,7 @@
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/security/authorization/authorization_engine.h"
#include "src/core/lib/security/authorization/grpc_authorization_engine.h"
#include "src/core/lib/security/context/security_context.h"
@ -106,7 +107,7 @@ void RbacFilter::CallData::RecvInitialMetadataReady(void* user_data,
}
}
if (!error.ok()) {
error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS,
error = grpc_error_set_int(error, StatusIntProperty::kRpcStatus,
GRPC_STATUS_PERMISSION_DENIED);
}
}

@ -577,7 +577,7 @@ static void close_transport_locked(grpc_binder_transport* gbt) {
gbt, gbt->registered_stream.begin()->second,
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("transport closed"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
grpc_core::StatusIntProperty::kRpcStatus, GRPC_STATUS_UNAVAILABLE));
}
}
@ -631,7 +631,8 @@ static void destroy_stream_locked(void* sp, grpc_error_handle /*error*/) {
cancel_stream_locked(
gbt, gbs,
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("destroy stream"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_UNAVAILABLE));
gbs->~grpc_binder_stream();
}

@ -53,6 +53,7 @@
#include "src/core/lib/event_engine/channel_args_endpoint_config.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/orphanable.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/gprpp/unique_type_name.h"
#include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/iomgr/exec_ctx.h"
@ -366,7 +367,8 @@ grpc_channel* grpc_channel_create(const char* target,
if (channel == nullptr) {
intptr_t integer;
grpc_status_code status = GRPC_STATUS_INTERNAL;
if (grpc_error_get_int(error, GRPC_ERROR_INT_GRPC_STATUS, &integer)) {
if (grpc_error_get_int(error, grpc_core::StatusIntProperty::kRpcStatus,
&integer)) {
status = static_cast<grpc_status_code>(integer);
}
channel = grpc_lame_client_channel_create(

@ -539,9 +539,10 @@ static void destroy_transport_locked(void* tp, grpc_error_handle /*error*/) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(tp);
t->destroying = 1;
close_transport_locked(
t, grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Transport destroyed"),
GRPC_ERROR_INT_OCCURRED_DURING_WRITE, t->write_state));
t,
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Transport destroyed"),
grpc_core::StatusIntProperty::kOccurredDuringWrite, t->write_state));
t->memory_owner.Reset();
// Must be the last line.
GRPC_CHTTP2_UNREF_TRANSPORT(t, "destroy");
@ -559,8 +560,9 @@ static void close_transport_locked(grpc_chttp2_transport* t,
cancel_pings(t, error);
if (t->closed_with_error.ok()) {
if (!grpc_error_has_clear_grpc_status(error)) {
error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS,
GRPC_STATUS_UNAVAILABLE);
error =
grpc_error_set_int(error, grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_UNAVAILABLE);
}
if (t->write_state != GRPC_CHTTP2_WRITE_STATE_IDLE) {
if (t->close_transport_on_writes_finished.ok()) {
@ -977,9 +979,10 @@ void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t,
grpc_error_set_int(
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("GOAWAY received"),
GRPC_ERROR_INT_HTTP2_ERROR, static_cast<intptr_t>(goaway_error)),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE),
GRPC_ERROR_STR_RAW_BYTES, goaway_text);
grpc_core::StatusIntProperty::kHttp2Error,
static_cast<intptr_t>(goaway_error)),
grpc_core::StatusIntProperty::kRpcStatus, GRPC_STATUS_UNAVAILABLE),
grpc_core::StatusStrProperty::kRawBytes, goaway_text);
GRPC_CHTTP2_IF_TRACING(
gpr_log(GPR_INFO, "transport %p got goaway with last stream id %d", t,
@ -1084,7 +1087,8 @@ static void maybe_start_some_streams(grpc_chttp2_transport* t) {
t, s,
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Stream IDs exhausted"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_UNAVAILABLE));
}
}
}
@ -1147,8 +1151,8 @@ void grpc_chttp2_complete_closure_step(grpc_chttp2_transport* t,
" write_state=", write_state_name(t->write_state), " refs=",
closure->next_data.scratch / CLOSURE_BARRIER_FIRST_REF_BIT, " flags=",
closure->next_data.scratch % CLOSURE_BARRIER_FIRST_REF_BIT));
cl_err = grpc_error_set_str(cl_err, GRPC_ERROR_STR_TARGET_ADDRESS,
t->peer_string);
cl_err = grpc_error_set_str(
cl_err, grpc_core::StatusStrProperty::kTargetAddress, t->peer_string);
}
cl_err = grpc_error_add_child(cl_err, error);
closure->error_data.error = grpc_core::internal::StatusAllocHeapPtr(cl_err);
@ -1256,7 +1260,8 @@ static void perform_stream_op_locked(void* stream_op,
grpc_error_set_int(
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Transport closed", &t->closed_with_error, 1),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_UNAVAILABLE));
}
} else {
GPR_ASSERT(s->id != 0);
@ -1690,13 +1695,15 @@ void grpc_chttp2_add_ping_strike(grpc_chttp2_transport* t) {
send_goaway(t,
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("too_many_pings"),
GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_ENHANCE_YOUR_CALM),
grpc_core::StatusIntProperty::kHttp2Error,
GRPC_HTTP2_ENHANCE_YOUR_CALM),
/*immediate_disconnect_hint=*/true);
// The transport will be closed after the write is done
close_transport_locked(
t, grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Too many pings"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
t,
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Too many pings"),
grpc_core::StatusIntProperty::kRpcStatus, GRPC_STATUS_UNAVAILABLE));
}
}
@ -2249,8 +2256,9 @@ static void end_all_the_calls(grpc_chttp2_transport* t,
intptr_t http2_error;
// If there is no explicit grpc or HTTP/2 error, set to UNAVAILABLE on server.
if (!t->is_client && !grpc_error_has_clear_grpc_status(error) &&
!grpc_error_get_int(error, GRPC_ERROR_INT_HTTP2_ERROR, &http2_error)) {
error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS,
!grpc_error_get_int(error, grpc_core::StatusIntProperty::kHttp2Error,
&http2_error)) {
error = grpc_error_set_int(error, grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_UNAVAILABLE);
}
cancel_unstarted_streams(t, error);
@ -2320,8 +2328,9 @@ static grpc_error_handle try_http_parsing(grpc_chttp2_transport* t) {
error = grpc_error_set_int(
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Trying to connect an http1.x server"),
GRPC_ERROR_INT_HTTP_STATUS, response.status),
GRPC_ERROR_INT_GRPC_STATUS,
grpc_core::StatusIntProperty::kHttpStatus,
response.status),
grpc_core::StatusIntProperty::kRpcStatus,
grpc_http2_status_to_grpc_status(response.status));
}
@ -2344,7 +2353,7 @@ static void read_action_locked(void* tp, grpc_error_handle error) {
if (!err.ok()) {
err = grpc_error_set_int(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Endpoint read failed", &err, 1),
GRPC_ERROR_INT_OCCURRED_DURING_WRITE,
grpc_core::StatusIntProperty::kOccurredDuringWrite,
t->write_state);
}
std::swap(err, error);
@ -2712,7 +2721,7 @@ static void keepalive_watchdog_fired_locked(void* arg,
close_transport_locked(
t, grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"keepalive watchdog timeout"),
GRPC_ERROR_INT_GRPC_STATUS,
grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_UNAVAILABLE));
}
} else {
@ -2809,11 +2818,12 @@ static void benign_reclaimer_locked(void* arg, grpc_error_handle error) {
gpr_log(GPR_INFO, "HTTP2: %s - send goaway to free memory",
t->peer_string.c_str());
}
send_goaway(t,
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Buffers full"),
GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_ENHANCE_YOUR_CALM),
/*immediate_disconnect_hint=*/true);
send_goaway(
t,
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Buffers full"),
grpc_core::StatusIntProperty::kHttp2Error,
GRPC_HTTP2_ENHANCE_YOUR_CALM),
/*immediate_disconnect_hint=*/true);
} else if (error.ok() && GRPC_TRACE_FLAG_ENABLED(grpc_resource_quota_trace)) {
gpr_log(GPR_INFO,
"HTTP2: %s - skip benign reclamation, there are still %" PRIdPTR
@ -2842,7 +2852,7 @@ static void destructive_reclaimer_locked(void* arg, grpc_error_handle error) {
grpc_chttp2_cancel_stream(
t, s,
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Buffers full"),
GRPC_ERROR_INT_HTTP2_ERROR,
grpc_core::StatusIntProperty::kHttp2Error,
GRPC_HTTP2_ENHANCE_YOUR_CALM));
if (n > 1) {
// Since we cancel one stream per destructive reclamation, if

@ -29,6 +29,7 @@
#include <grpc/support/log.h>
#include "src/core/ext/transport/chttp2/transport/internal.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/slice/slice.h"
#include "src/core/lib/slice/slice_buffer.h"
#include "src/core/lib/transport/transport.h"
@ -105,7 +106,7 @@ grpc_core::Poll<grpc_error_handle> grpc_deframe_unprocessed_incoming_frames(
default:
error = GRPC_ERROR_CREATE_FROM_CPP_STRING(
absl::StrFormat("Bad GRPC frame type 0x%02x", header[0]));
error = grpc_error_set_int(error, GRPC_ERROR_INT_STREAM_ID,
error = grpc_error_set_int(error, grpc_core::StatusIntProperty::kStreamId,
static_cast<intptr_t>(s->id));
return error;
}

@ -33,6 +33,7 @@
#include "src/core/ext/transport/chttp2/transport/hpack_encoder.h"
#include "src/core/ext/transport/chttp2/transport/internal.h"
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/transport/http2_errors.h"
#include "src/core/lib/transport/metadata_batch.h"
@ -117,9 +118,10 @@ grpc_error_handle grpc_chttp2_rst_stream_parser_parse(void* parser,
error = grpc_error_set_int(
grpc_error_set_str(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("RST_STREAM"),
GRPC_ERROR_STR_GRPC_MESSAGE,
grpc_core::StatusStrProperty::kGrpcMessage,
absl::StrCat("Received RST_STREAM with error code ", reason)),
GRPC_ERROR_INT_HTTP2_ERROR, static_cast<intptr_t>(reason));
grpc_core::StatusIntProperty::kHttp2Error,
static_cast<intptr_t>(reason));
}
grpc_chttp2_mark_stream_closed(t, s, true, true, error);
}

@ -49,6 +49,7 @@
#include "src/core/ext/transport/chttp2/transport/internal.h"
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/experiments/experiments.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/combiner.h"
#include "src/core/lib/slice/slice.h"
@ -1194,9 +1195,9 @@ class HPackParser::Parser {
return grpc_error_set_int(
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Invalid HPACK index received"),
GRPC_ERROR_INT_INDEX,
StatusIntProperty::kIndex,
static_cast<intptr_t>(index)),
GRPC_ERROR_INT_SIZE,
StatusIntProperty::kSize,
static_cast<intptr_t>(this->table_->num_entries()));
},
std::move(result));
@ -1215,7 +1216,7 @@ class HPackParser::Parser {
return grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"received initial metadata size exceeds limit"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_RESOURCE_EXHAUSTED);
StatusIntProperty::kRpcStatus, GRPC_STATUS_RESOURCE_EXHAUSTED);
},
false);
}

@ -48,6 +48,7 @@
#include "src/core/lib/channel/channelz.h"
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/gprpp/time.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/transport/bdp_estimator.h"
@ -713,7 +714,8 @@ static grpc_error_handle parse_frame_slice(grpc_chttp2_transport* t,
intptr_t unused;
if (GPR_LIKELY(err.ok())) {
return err;
} else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, &unused)) {
} else if (grpc_error_get_int(err, grpc_core::StatusIntProperty::kStreamId,
&unused)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) {
gpr_log(GPR_ERROR, "%s", grpc_error_std_string(err).c_str());
}

@ -47,6 +47,7 @@
#include "src/core/ext/transport/cronet/transport/cronet_status.h"
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/iomgr/error.h"
@ -321,7 +322,8 @@ static grpc_error_handle make_error_with_desc(int error_code,
return grpc_error_set_int(GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrFormat(
"Cronet error code:%d, Cronet error detail:%s",
cronet_internal_error_code, desc)),
GRPC_ERROR_INT_GRPC_STATUS, error_code);
grpc_core::StatusIntProperty::kRpcStatus,
error_code);
}
inline op_and_state::op_and_state(stream_obj* s,

@ -47,6 +47,7 @@
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/gprpp/time.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/endpoint.h"
@ -1101,7 +1102,8 @@ void close_transport_locked(inproc_transport* t) {
t->stream_list,
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Transport closed"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_UNAVAILABLE));
}
}
}
@ -1243,7 +1245,8 @@ grpc_channel* grpc_inproc_channel_create(grpc_server* server,
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)) {
if (grpc_error_get_int(error, grpc_core::StatusIntProperty::kRpcStatus,
&integer)) {
status = static_cast<grpc_status_code>(integer);
}
// client_transport was destroyed when grpc_channel_create_internal saw an
@ -1260,7 +1263,8 @@ grpc_channel* grpc_inproc_channel_create(grpc_server* server,
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)) {
if (grpc_error_get_int(error, grpc_core::StatusIntProperty::kRpcStatus,
&integer)) {
status = static_cast<grpc_status_code>(integer);
}
grpc_transport_destroy(client_transport);

@ -71,6 +71,7 @@
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/host_port.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/gprpp/unique_type_name.h"
#include "src/core/lib/iomgr/endpoint.h"
@ -1195,11 +1196,11 @@ ServerConfigSelector::CallConfig XdsServerConfigFetcher::ListenerWatcher::
auto vhost_index = XdsRouting::FindVirtualHostForDomain(
VirtualHostListIterator(&virtual_hosts_), authority);
if (!vhost_index.has_value()) {
call_config.error =
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrCat(
"could not find VirtualHost for ", authority,
" in RouteConfiguration")),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
call_config.error = grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_CPP_STRING(
absl::StrCat("could not find VirtualHost for ", authority,
" in RouteConfiguration")),
StatusIntProperty::kRpcStatus, GRPC_STATUS_UNAVAILABLE);
return call_config;
}
auto& virtual_host = virtual_hosts_[vhost_index.value()];
@ -1212,7 +1213,7 @@ ServerConfigSelector::CallConfig XdsServerConfigFetcher::ListenerWatcher::
call_config.error = grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Matching route has unsupported action"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
StatusIntProperty::kRpcStatus, GRPC_STATUS_UNAVAILABLE);
return call_config;
}
if (route.method_config != nullptr) {
@ -1224,7 +1225,7 @@ ServerConfigSelector::CallConfig XdsServerConfigFetcher::ListenerWatcher::
}
call_config.error = grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("No route matched"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
StatusIntProperty::kRpcStatus, GRPC_STATUS_UNAVAILABLE);
return call_config;
}

@ -27,6 +27,7 @@
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/event_engine/default_event_engine.h"
#include "src/core/lib/gprpp/manual_constructor.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/slice/slice.h"
@ -346,10 +347,10 @@ class ClientCallData::PollContext {
grpc_error_handle error = grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"early return from promise based filter"),
GRPC_ERROR_INT_GRPC_STATUS,
StatusIntProperty::kRpcStatus,
*md->get_pointer(GrpcStatusMetadata()));
if (auto* message = md->get_pointer(GrpcMessageMetadata())) {
error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE,
error = grpc_error_set_str(error, StatusStrProperty::kGrpcMessage,
message->as_string_view());
}
self_->cancelled_error_ = error;
@ -1223,10 +1224,10 @@ void ServerCallData::WakeInsideCombiner(Flusher* flusher) {
grpc_error_handle error =
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"early return from promise based filter"),
GRPC_ERROR_INT_GRPC_STATUS,
StatusIntProperty::kRpcStatus,
*md->get_pointer(GrpcStatusMetadata()));
if (auto* message = md->get_pointer(GrpcMessageMetadata())) {
error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE,
error = grpc_error_set_str(error, StatusStrProperty::kGrpcMessage,
message->as_string_view());
}
Cancel(error, flusher);

@ -47,7 +47,6 @@ struct upb_Arena;
namespace grpc_core {
/// This enum should have the same value of grpc_error_ints
// TODO(veblush): Use camel-case names once migration to absl::Status is done.
enum class StatusIntProperty {
/// 'errno' from the operating system
kErrorNo,
@ -85,7 +84,6 @@ enum class StatusIntProperty {
};
/// This enum should have the same value of grpc_error_strs
// TODO(veblush): Use camel-case names once migration to absl::Status is done.
enum class StatusStrProperty {
/// top-level textual description of this error
kDescription,

@ -39,6 +39,7 @@
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_args_preconditioning.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/http/format_request.h"
#include "src/core/lib/http/parser.h"
#include "src/core/lib/iomgr/endpoint.h"
@ -249,7 +250,7 @@ void HttpRequest::AppendError(grpc_error_handle error) {
overall_error_ = grpc_error_add_child(
overall_error_,
grpc_error_set_str(
error, GRPC_ERROR_STR_TARGET_ADDRESS,
error, StatusStrProperty::kTargetAddress,
addr_text.ok() ? addr_text.value() : addr_text.status().ToString()));
}

@ -81,7 +81,7 @@ void CFStreamHandle::ReadCallback(CFReadStreamRef stream,
stream_error = CFReadStreamCopyError(stream);
error = grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_CFERROR(stream_error, "read error"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
grpc_core::StatusIntProperty::kRpcStatus, GRPC_STATUS_UNAVAILABLE);
CFRelease(stream_error);
handle->open_event_.SetShutdown(error);
handle->write_event_.SetShutdown(error);
@ -115,7 +115,7 @@ void CFStreamHandle::WriteCallback(CFWriteStreamRef stream,
stream_error = CFWriteStreamCopyError(stream);
error = grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_CFERROR(stream_error, "write error"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
grpc_core::StatusIntProperty::kRpcStatus, GRPC_STATUS_UNAVAILABLE);
CFRelease(stream_error);
handle->open_event_.SetShutdown(error);
handle->write_event_.SetShutdown(error);

@ -107,9 +107,9 @@ static void CFStreamRef(CFStreamEndpoint* ep) { gpr_ref(&ep->refcount); }
static grpc_error_handle CFStreamAnnotateError(grpc_error_handle src_error,
CFStreamEndpoint* ep) {
return grpc_error_set_str(
grpc_error_set_int(src_error, GRPC_ERROR_INT_GRPC_STATUS,
grpc_error_set_int(src_error, grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_UNAVAILABLE),
GRPC_ERROR_STR_TARGET_ADDRESS, ep->peer_string);
grpc_core::StatusStrProperty::kTargetAddress, ep->peer_string);
}
static void CallReadCb(CFStreamEndpoint* ep, grpc_error_handle error) {

@ -98,27 +98,26 @@ absl::Status grpc_wsa_error(const grpc_core::DebugLocation& location, int err,
#endif
grpc_error_handle grpc_error_set_int(grpc_error_handle src,
grpc_error_ints which, intptr_t value) {
grpc_core::StatusIntProperty which,
intptr_t value) {
if (src.ok()) {
src = absl::UnknownError("");
StatusSetInt(&src, grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_OK);
}
grpc_core::StatusSetInt(
&src, static_cast<grpc_core::StatusIntProperty>(which), value);
grpc_core::StatusSetInt(&src, which, value);
return src;
}
bool grpc_error_get_int(grpc_error_handle error, grpc_error_ints which,
intptr_t* p) {
absl::optional<intptr_t> value = grpc_core::StatusGetInt(
error, static_cast<grpc_core::StatusIntProperty>(which));
bool grpc_error_get_int(grpc_error_handle error,
grpc_core::StatusIntProperty which, intptr_t* p) {
absl::optional<intptr_t> value = grpc_core::StatusGetInt(error, which);
if (value.has_value()) {
*p = *value;
return true;
} else {
// TODO(veblush): Remove this once absl::Status migration is done
if (which == GRPC_ERROR_INT_GRPC_STATUS) {
if (which == grpc_core::StatusIntProperty::kRpcStatus) {
switch (error.code()) {
case absl::StatusCode::kOk:
*p = GRPC_STATUS_OK;
@ -138,14 +137,14 @@ 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,
grpc_core::StatusStrProperty which,
absl::string_view str) {
if (src.ok()) {
src = absl::UnknownError("");
StatusSetInt(&src, grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_OK);
}
if (which == GRPC_ERROR_STR_DESCRIPTION) {
if (which == grpc_core::StatusStrProperty::kDescription) {
// 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);
@ -155,17 +154,16 @@ grpc_error_handle grpc_error_set_str(grpc_error_handle src,
});
return s;
} else {
grpc_core::StatusSetStr(
&src, static_cast<grpc_core::StatusStrProperty>(which), str);
grpc_core::StatusSetStr(&src, which, str);
}
return src;
}
bool grpc_error_get_str(grpc_error_handle error, grpc_error_strs which,
std::string* s) {
if (which == GRPC_ERROR_STR_DESCRIPTION) {
// absl::Status uses the message field for GRPC_ERROR_STR_DESCRIPTION
// instead of using payload.
bool grpc_error_get_str(grpc_error_handle error,
grpc_core::StatusStrProperty which, std::string* s) {
if (which == grpc_core::StatusStrProperty::kDescription) {
// absl::Status uses the message field for
// grpc_core::StatusStrProperty::kDescription instead of using payload.
absl::string_view msg = error.message();
if (msg.empty()) {
return false;
@ -174,14 +172,13 @@ bool grpc_error_get_str(grpc_error_handle error, grpc_error_strs which,
return true;
}
} else {
absl::optional<std::string> value = grpc_core::StatusGetStr(
error, static_cast<grpc_core::StatusStrProperty>(which));
absl::optional<std::string> value = grpc_core::StatusGetStr(error, 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) {
if (which == grpc_core::StatusStrProperty::kGrpcMessage) {
switch (error.code()) {
case absl::StatusCode::kOk:
*s = "";

@ -42,6 +42,7 @@
typedef absl::Status grpc_error_handle;
/// TODO(veblush): Remove this enum once migration is done
typedef enum {
/// 'errno' from the operating system
GRPC_ERROR_INT_ERRNO =
@ -92,6 +93,7 @@ typedef enum {
GRPC_ERROR_INT_MAX,
} grpc_error_ints;
/// TODO(veblush): Remove this enum once migration is done
typedef enum {
/// top-level textual description of this error
GRPC_ERROR_STR_DESCRIPTION =
@ -128,14 +130,6 @@ typedef enum {
GRPC_ERROR_STR_MAX,
} grpc_error_strs;
typedef enum {
/// timestamp of error creation
GRPC_ERROR_TIME_CREATED,
/// Must always be last
GRPC_ERROR_TIME_MAX,
} grpc_error_times;
std::string grpc_error_std_string(grpc_error_handle error);
// debug only toggles that allow for a sanity to check that ensures we will
@ -217,18 +211,44 @@ absl::Status grpc_wsa_error(const grpc_core::DebugLocation& location, int err,
grpc_wsa_error(DEBUG_LOCATION, err, call_name)
grpc_error_handle grpc_error_set_int(grpc_error_handle src,
grpc_error_ints which,
grpc_core::StatusIntProperty which,
intptr_t value) GRPC_MUST_USE_RESULT;
/// It is an error to pass nullptr as `p`. Caller should allocate a phony
/// intptr_t for `p`, even if the value of `p` is not used.
bool grpc_error_get_int(grpc_error_handle error, grpc_error_ints which,
intptr_t* p);
bool grpc_error_get_int(grpc_error_handle error,
grpc_core::StatusIntProperty which, intptr_t* p);
grpc_error_handle grpc_error_set_str(
grpc_error_handle src, grpc_error_strs which,
grpc_error_handle src, grpc_core::StatusStrProperty which,
absl::string_view str) GRPC_MUST_USE_RESULT;
/// Returns false if the specified string is not set.
bool grpc_error_get_str(grpc_error_handle error, grpc_error_strs which,
std::string* str);
bool grpc_error_get_str(grpc_error_handle error,
grpc_core::StatusStrProperty which, std::string* str);
/// TODO(veblush): Remove these functions once migration is done
/// PLEASE DON'T USE: begin
inline grpc_error_handle grpc_error_set_int(grpc_error_handle src,
grpc_error_ints which,
intptr_t value) {
return grpc_error_set_int(
src, static_cast<grpc_core::StatusIntProperty>(which), value);
}
inline bool grpc_error_get_int(grpc_error_handle error, grpc_error_ints which,
intptr_t* p) {
return grpc_error_get_int(
error, static_cast<grpc_core::StatusIntProperty>(which), p);
}
inline grpc_error_handle grpc_error_set_str(grpc_error_handle src,
grpc_error_strs which,
absl::string_view str) {
return grpc_error_set_str(
src, static_cast<grpc_core::StatusStrProperty>(which), str);
}
inline bool grpc_error_get_str(grpc_error_handle error, grpc_error_strs which,
std::string* str) {
return grpc_error_get_str(
error, static_cast<grpc_core::StatusStrProperty>(which), str);
}
/// PLEASE DON'T USE: end
/// Add a child error: an error that is believed to have contributed to this
/// error occurring. Allows root causing high level errors from lower level

@ -493,7 +493,7 @@ static grpc_error_handle fd_shutdown_error(grpc_fd* fd) {
} else {
return grpc_error_set_int(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"FD shutdown", &fd->shutdown_error, 1),
GRPC_ERROR_INT_GRPC_STATUS,
grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_UNAVAILABLE);
}
}
@ -504,7 +504,7 @@ static void notify_on_locked(grpc_fd* fd, grpc_closure** st,
grpc_core::ExecCtx::Run(
DEBUG_LOCATION, closure,
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("FD shutdown"),
GRPC_ERROR_INT_GRPC_STATUS,
grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_UNAVAILABLE));
} else if (*st == CLOSURE_NOT_READY) {
/* not ready ==> switch to a waiting state by setting the closure */

@ -70,9 +70,7 @@ end:
grpc_error_handle error_out =
grpc_error_set_str(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Failed to load file", &error, 1),
GRPC_ERROR_STR_FILENAME,
filename);
grpc_core::StatusStrProperty::kFilename, filename);
error = error_out;
}
GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX;

@ -32,7 +32,7 @@
inline grpc_error_handle grpc_socket_error(char* error) {
return grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(error),
GRPC_ERROR_INT_GRPC_STATUS,
grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_UNAVAILABLE);
}

@ -107,14 +107,14 @@ NativeDNSResolver::LookupHostnameBlocking(absl::string_view name,
if (host.empty()) {
err = grpc_error_set_str(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("unparseable host:port"),
GRPC_ERROR_STR_TARGET_ADDRESS, name);
StatusStrProperty::kTargetAddress, name);
goto done;
}
if (port.empty()) {
if (default_port.empty()) {
err = grpc_error_set_str(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("no port in name"),
GRPC_ERROR_STR_TARGET_ADDRESS, name);
StatusStrProperty::kTargetAddress, name);
goto done;
}
port = std::string(default_port);
@ -145,10 +145,10 @@ NativeDNSResolver::LookupHostnameBlocking(absl::string_view name,
grpc_error_set_str(
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING(gai_strerror(s)),
GRPC_ERROR_INT_ERRNO, s),
GRPC_ERROR_STR_OS_ERROR, gai_strerror(s)),
GRPC_ERROR_STR_SYSCALL, "getaddrinfo"),
GRPC_ERROR_STR_TARGET_ADDRESS, name);
StatusIntProperty::kErrorNo, s),
StatusStrProperty::kOsError, gai_strerror(s)),
StatusStrProperty::kSyscall, "getaddrinfo"),
StatusStrProperty::kTargetAddress, name);
goto done;
}
// Success path: fill in addrs

@ -422,7 +422,8 @@ static grpc_error_handle error_for_fd(int fd,
if (fd >= 0) return absl::OkStatus();
auto addr_str = grpc_sockaddr_to_string(addr, false);
grpc_error_handle err = grpc_error_set_str(
GRPC_OS_ERROR(errno, "socket"), GRPC_ERROR_STR_TARGET_ADDRESS,
GRPC_OS_ERROR(errno, "socket"),
grpc_core::StatusStrProperty::kTargetAddress,
addr_str.ok() ? addr_str.value() : addr_str.status().ToString());
return err;
}

@ -186,8 +186,8 @@ static void on_writable(void* acp, grpc_error_handle error) {
gpr_mu_lock(&ac->mu);
if (!error.ok()) {
error =
grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR, "Timeout occurred");
error = grpc_error_set_str(error, grpc_core::StatusStrProperty::kOsError,
"Timeout occurred");
goto finish;
}
@ -261,12 +261,15 @@ finish:
gpr_mu_unlock(&ac->mu);
if (!error.ok()) {
std::string str;
bool ret = grpc_error_get_str(error, GRPC_ERROR_STR_DESCRIPTION, &str);
bool ret = grpc_error_get_str(
error, grpc_core::StatusStrProperty::kDescription, &str);
GPR_ASSERT(ret);
std::string description =
absl::StrCat("Failed to connect to remote host: ", str);
error = grpc_error_set_str(error, GRPC_ERROR_STR_DESCRIPTION, description);
error = grpc_error_set_str(error, GRPC_ERROR_STR_TARGET_ADDRESS, addr_str);
error = grpc_error_set_str(
error, grpc_core::StatusStrProperty::kDescription, description);
error = grpc_error_set_str(
error, grpc_core::StatusStrProperty::kTargetAddress, addr_str);
}
if (done) {
// This is safe even outside the lock, because "done", the sentinel, is
@ -350,8 +353,8 @@ int64_t grpc_tcp_client_create_from_prepared_fd(
// Connection already failed. Return 0 to discourage any cancellation
// attempts.
grpc_error_handle error = GRPC_OS_ERROR(errno, "connect");
error = grpc_error_set_str(error, GRPC_ERROR_STR_TARGET_ADDRESS,
addr_uri.value());
error = grpc_error_set_str(
error, grpc_core::StatusStrProperty::kTargetAddress, addr_uri.value());
grpc_fd_orphan(fdobj, nullptr, nullptr, "tcp_client_connect_error");
grpc_core::ExecCtx::Run(DEBUG_LOCATION, closure, error);
return 0;

@ -221,7 +221,7 @@ failure:
grpc_error_handle final_error = grpc_error_set_str(
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Failed to connect",
&error, 1),
GRPC_ERROR_STR_TARGET_ADDRESS,
grpc_core::StatusStrProperty::kTargetAddress,
addr_uri.ok() ? *addr_uri : addr_uri.status().ToString());
if (socket != NULL) {
grpc_winsocket_destroy(socket);

@ -713,11 +713,12 @@ static grpc_error_handle tcp_annotate_error(grpc_error_handle src_error,
grpc_tcp* tcp) {
return grpc_error_set_str(
grpc_error_set_int(
grpc_error_set_int(src_error, GRPC_ERROR_INT_FD, tcp->fd),
grpc_error_set_int(src_error, grpc_core::StatusIntProperty::kFd,
tcp->fd),
/* All tcp errors are marked with UNAVAILABLE so that application may
* choose to retry. */
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE),
GRPC_ERROR_STR_TARGET_ADDRESS, tcp->peer_string);
grpc_core::StatusIntProperty::kRpcStatus, GRPC_STATUS_UNAVAILABLE),
grpc_core::StatusStrProperty::kTargetAddress, tcp->peer_string);
}
static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error_handle error);

@ -218,7 +218,7 @@ error:
grpc_error_handle ret =
grpc_error_set_int(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Unable to configure socket", &err, 1),
GRPC_ERROR_INT_FD, fd);
grpc_core::StatusIntProperty::kFd, fd);
return ret;
}

@ -229,9 +229,9 @@ failure:
grpc_error_set_str(
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Failed to prepare server socket", &error, 1),
GRPC_ERROR_STR_TARGET_ADDRESS,
grpc_core::StatusStrProperty::kTargetAddress,
addr_uri.ok() ? *addr_uri : addr_uri.status().ToString()),
GRPC_ERROR_INT_FD, (intptr_t)sock);
grpc_core::StatusIntProperty::kFd, (intptr_t)sock);
if (sock != INVALID_SOCKET) closesocket(sock);
return error;
}

@ -222,7 +222,7 @@ static void on_read(void* tcpp, grpc_error_handle error) {
? GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"TCP stream shutting down", &tcp->shutdown_error, 1)
: GRPC_ERROR_CREATE_FROM_STATIC_STRING("End of TCP stream"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
grpc_core::StatusIntProperty::kRpcStatus, GRPC_STATUS_UNAVAILABLE);
}
}
}
@ -255,7 +255,7 @@ static void win_read(grpc_endpoint* ep, grpc_slice_buffer* read_slices,
grpc_error_set_int(
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"TCP socket is shutting down", &tcp->shutdown_error, 1),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
grpc_core::StatusIntProperty::kRpcStatus, GRPC_STATUS_UNAVAILABLE));
return;
}
@ -369,7 +369,7 @@ static void win_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
grpc_error_set_int(
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"TCP socket is shutting down", &tcp->shutdown_error, 1),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
grpc_core::StatusIntProperty::kRpcStatus, GRPC_STATUS_UNAVAILABLE));
return;
}

@ -47,6 +47,7 @@
#include "src/core/lib/gprpp/env.h"
#include "src/core/lib/gprpp/host_port.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/gprpp/time.h"
#include "src/core/lib/http/httpcli.h"
@ -326,7 +327,8 @@ static grpc_error_handle create_default_creds_from_path(
if (json.type() != Json::Type::OBJECT) {
error = grpc_error_set_str(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed to parse JSON"),
GRPC_ERROR_STR_RAW_BYTES, grpc_core::StringViewFromSlice(creds_data));
grpc_core::StatusStrProperty::kRawBytes,
grpc_core::StringViewFromSlice(creds_data));
goto end;
}

@ -39,6 +39,7 @@
#include "src/core/lib/channel/context.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/call_combiner.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/error.h"
@ -209,7 +210,7 @@ static void on_md_processing_done(
}
error = grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_details),
GRPC_ERROR_INT_GRPC_STATUS, status);
grpc_core::StatusIntProperty::kRpcStatus, status);
}
on_md_processing_done_inner(elem, consumed_md, num_consumed_md, response_md,
num_response_md, error);

@ -20,9 +20,12 @@
#include "src/core/lib/security/transport/tsi_error.h"
#include "src/core/lib/gprpp/status_helper.h"
grpc_error_handle grpc_set_tsi_error_result(grpc_error_handle error,
tsi_result result) {
return grpc_error_set_int(grpc_error_set_str(error, GRPC_ERROR_STR_TSI_ERROR,
tsi_result_to_string(result)),
GRPC_ERROR_INT_TSI_CODE, result);
return grpc_error_set_int(
grpc_error_set_str(error, grpc_core::StatusStrProperty::kTsiError,
tsi_result_to_string(result)),
grpc_core::StatusIntProperty::kTsiCode, result);
}

@ -73,6 +73,7 @@
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/ref_counted.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/iomgr/call_combiner.h"
#include "src/core/lib/iomgr/exec_ctx.h"
@ -309,8 +310,8 @@ void Call::CancelWithStatus(grpc_status_code status, const char* description) {
// guarantee that can be short-lived.
CancelWithError(grpc_error_set_int(
grpc_error_set_str(GRPC_ERROR_CREATE_FROM_COPIED_STRING(description),
GRPC_ERROR_STR_GRPC_MESSAGE, description),
GRPC_ERROR_INT_GRPC_STATUS, status));
StatusStrProperty::kGrpcMessage, description),
StatusIntProperty::kRpcStatus, status));
}
void Call::PropagateCancellationToChildren() {
@ -1019,15 +1020,15 @@ void FilterStackCall::RecvTrailingFilter(grpc_metadata_batch* b,
error = grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_CPP_STRING(
absl::StrCat("Error received from peer ", peer)),
GRPC_ERROR_INT_GRPC_STATUS, static_cast<intptr_t>(status_code));
StatusIntProperty::kRpcStatus, static_cast<intptr_t>(status_code));
gpr_free(peer);
}
auto grpc_message = b->Take(GrpcMessageMetadata());
if (grpc_message.has_value()) {
error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE,
error = grpc_error_set_str(error, StatusStrProperty::kGrpcMessage,
grpc_message->as_string_view());
} else if (!error.ok()) {
error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, "");
error = grpc_error_set_str(error, StatusStrProperty::kGrpcMessage, "");
}
SetFinalStatus(error);
} else if (!is_client()) {
@ -1037,7 +1038,7 @@ void FilterStackCall::RecvTrailingFilter(grpc_metadata_batch* b,
"Received trailing metadata with no error and no status");
SetFinalStatus(grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("No status received"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNKNOWN));
StatusIntProperty::kRpcStatus, GRPC_STATUS_UNKNOWN));
}
}
PublishAppMetadata(b, true);
@ -1553,7 +1554,7 @@ grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops,
: grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Server returned error"),
GRPC_ERROR_INT_GRPC_STATUS,
StatusIntProperty::kRpcStatus,
static_cast<intptr_t>(
op->data.send_status_from_server.status));
if (op->data.send_status_from_server.status_details != nullptr) {
@ -1563,7 +1564,7 @@ grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops,
*op->data.send_status_from_server.status_details)));
if (!status_error.ok()) {
status_error = grpc_error_set_str(
status_error, GRPC_ERROR_STR_GRPC_MESSAGE,
status_error, StatusStrProperty::kGrpcMessage,
StringViewFromSlice(
*op->data.send_status_from_server.status_details));
}

@ -47,6 +47,7 @@
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/mpscq.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/pollset_set.h"
#include "src/core/lib/slice/slice_internal.h"
@ -472,7 +473,7 @@ class ChannelBroadcaster {
send_goaway
? grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server shutdown"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_OK)
StatusIntProperty::kRpcStatus, GRPC_STATUS_OK)
: absl::OkStatus();
sc->slice = grpc_slice_from_copied_string("Server shutdown");
op->disconnect_with_error = send_disconnect;

@ -28,6 +28,7 @@
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gprpp/bitset.h"
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/error.h"
static grpc_error_handle conforms_to(const grpc_slice& slice,
@ -43,9 +44,10 @@ static grpc_error_handle conforms_to(const grpc_slice& slice,
GRPC_SLICE_LENGTH(slice), GPR_DUMP_HEX | GPR_DUMP_ASCII, &len));
grpc_error_handle error = grpc_error_set_str(
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(err_desc),
GRPC_ERROR_INT_OFFSET,
grpc_core::StatusIntProperty::kOffset,
p - GRPC_SLICE_START_PTR(slice)),
GRPC_ERROR_STR_RAW_BYTES, absl::string_view(ptr.get(), len));
grpc_core::StatusStrProperty::kRawBytes,
absl::string_view(ptr.get(), len));
return error;
}
}

@ -32,7 +32,7 @@
#include "src/core/lib/transport/status_conversion.h"
static grpc_error_handle recursively_find_error_with_field(
grpc_error_handle error, grpc_error_ints which) {
grpc_error_handle error, grpc_core::StatusIntProperty which) {
intptr_t unused;
// If the error itself has a status code, return it.
if (grpc_error_get_int(error, which, &unused)) {
@ -56,10 +56,10 @@ void grpc_error_get_status(grpc_error_handle error,
if (code != nullptr) *code = GRPC_STATUS_OK;
if (message != nullptr) {
// Normally, we call grpc_error_get_str(
// error, GRPC_ERROR_STR_GRPC_MESSAGE, message).
// error, grpc_core::StatusStrProperty::kGrpcMessage, message).
// We can fastpath since we know that:
// 1) Error is null
// 2) which == GRPC_ERROR_STR_GRPC_MESSAGE
// 2) which == grpc_core::StatusStrProperty::kGrpcMessage
// 3) The resulting message is statically known.
// 4) Said resulting message is "".
// This means 3 movs, instead of 10s of instructions and a strlen.
@ -73,13 +73,13 @@ void grpc_error_get_status(grpc_error_handle error,
// Start with the parent error and recurse through the tree of children
// until we find the first one that has a status code.
grpc_error_handle found_error =
recursively_find_error_with_field(error, GRPC_ERROR_INT_GRPC_STATUS);
grpc_error_handle found_error = recursively_find_error_with_field(
error, grpc_core::StatusIntProperty::kRpcStatus);
if (found_error.ok()) {
/// If no grpc-status exists, retry through the tree to find a http2 error
/// code
found_error =
recursively_find_error_with_field(error, GRPC_ERROR_INT_HTTP2_ERROR);
found_error = recursively_find_error_with_field(
error, grpc_core::StatusIntProperty::kHttp2Error);
}
// If we found an error with a status code above, use that; otherwise,
@ -88,9 +88,11 @@ void grpc_error_get_status(grpc_error_handle error,
grpc_status_code status = GRPC_STATUS_UNKNOWN;
intptr_t integer;
if (grpc_error_get_int(found_error, GRPC_ERROR_INT_GRPC_STATUS, &integer)) {
if (grpc_error_get_int(found_error, grpc_core::StatusIntProperty::kRpcStatus,
&integer)) {
status = static_cast<grpc_status_code>(integer);
} else if (grpc_error_get_int(found_error, GRPC_ERROR_INT_HTTP2_ERROR,
} else if (grpc_error_get_int(found_error,
grpc_core::StatusIntProperty::kHttp2Error,
&integer)) {
status = grpc_http2_error_to_grpc_status(
static_cast<grpc_http2_error_code>(integer), deadline);
@ -104,9 +106,11 @@ void grpc_error_get_status(grpc_error_handle error,
}
if (http_error != nullptr) {
if (grpc_error_get_int(found_error, GRPC_ERROR_INT_HTTP2_ERROR, &integer)) {
if (grpc_error_get_int(
found_error, grpc_core::StatusIntProperty::kHttp2Error, &integer)) {
*http_error = static_cast<grpc_http2_error_code>(integer);
} else if (grpc_error_get_int(found_error, GRPC_ERROR_INT_GRPC_STATUS,
} else if (grpc_error_get_int(found_error,
grpc_core::StatusIntProperty::kRpcStatus,
&integer)) {
*http_error =
grpc_status_to_http2_error(static_cast<grpc_status_code>(integer));
@ -119,9 +123,10 @@ void grpc_error_get_status(grpc_error_handle error,
// If the error has a status message, use it. Otherwise, fall back to
// the error description.
if (message != nullptr) {
if (!grpc_error_get_str(found_error, GRPC_ERROR_STR_GRPC_MESSAGE,
message)) {
if (!grpc_error_get_str(found_error, GRPC_ERROR_STR_DESCRIPTION,
if (!grpc_error_get_str(
found_error, grpc_core::StatusStrProperty::kGrpcMessage, message)) {
if (!grpc_error_get_str(found_error,
grpc_core::StatusStrProperty::kDescription,
message)) {
*message = grpc_error_std_string(error);
}
@ -147,12 +152,14 @@ grpc_error_handle absl_status_to_grpc_error(absl::Status status) {
}
return grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STRING_VIEW(status.message()),
GRPC_ERROR_INT_GRPC_STATUS, static_cast<grpc_status_code>(status.code()));
grpc_core::StatusIntProperty::kRpcStatus,
static_cast<grpc_status_code>(status.code()));
}
bool grpc_error_has_clear_grpc_status(grpc_error_handle error) {
intptr_t unused;
if (grpc_error_get_int(error, GRPC_ERROR_INT_GRPC_STATUS, &unused)) {
if (grpc_error_get_int(error, grpc_core::StatusIntProperty::kRpcStatus,
&unused)) {
return true;
}
std::vector<absl::Status> children = grpc_core::StatusGetChildren(error);

@ -56,8 +56,8 @@ grpc_error_handle absl_status_to_grpc_error(absl::Status status);
/// A utility function to check whether there is a clear status code that
/// doesn't need to be guessed in \a error. This means that \a error or some
/// child has GRPC_ERROR_INT_GRPC_STATUS set, or that it is absl::OkStatus() or
/// absl::CancelledError()
/// child has grpc_core::StatusIntProperty::kRpcStatus set, or that it is
/// absl::OkStatus() or absl::CancelledError()
bool grpc_error_has_clear_grpc_status(grpc_error_handle error);
#endif /* GRPC_CORE_LIB_TRANSPORT_ERROR_UTILS_H */

@ -359,10 +359,11 @@ struct grpc_transport_stream_op_batch_payload {
/** Forcefully close this stream.
The HTTP2 semantics should be:
- server side: if cancel_error has GRPC_ERROR_INT_GRPC_STATUS, and
trailing metadata has not been sent, send trailing metadata with status
and message from cancel_error (use grpc_error_get_status) followed by
a RST_STREAM with error=GRPC_CHTTP2_NO_ERROR to force a full close
- server side: if cancel_error has
grpc_core::StatusIntProperty::kRpcStatus, and trailing metadata has not
been sent, send trailing metadata with status and message from cancel_error
(use grpc_error_get_status) followed by a RST_STREAM with
error=GRPC_CHTTP2_NO_ERROR to force a full close
- at all other times: use grpc_error_get_status to get a status code, and
convert to a HTTP2 error code using
grpc_chttp2_grpc_status_to_http2_error. Send a RST_STREAM with this

@ -85,5 +85,6 @@ grpc_cc_library(
"//:json_args",
"//:json_object_loader",
"//:slice_refcount",
"//:status_helper",
],
)

@ -28,6 +28,7 @@
#include <grpc/status.h>
#include "src/core/lib/gprpp/env.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/load_file.h"
#include "src/core/lib/json/json.h"
@ -51,8 +52,9 @@ absl::StatusOr<std::string> GetGcpObservabilityConfigContents() {
grpc_error_handle error =
grpc_load_file(path->c_str(), /*add_null_terminator=*/true, &contents);
if (!error.ok()) {
return grpc_error_to_absl_status(grpc_error_set_int(
error, GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_FAILED_PRECONDITION));
return grpc_error_to_absl_status(
grpc_error_set_int(error, grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_FAILED_PRECONDITION));
}
std::string contents_str(grpc_core::StringViewFromSlice(contents));
grpc_slice_unref(contents);

@ -33,6 +33,7 @@
#include "src/core/lib/channel/channel_stack_builder.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/surface/channel_init.h"
@ -210,7 +211,7 @@ static void recv_im_ready(void* arg, grpc_error_handle error) {
DEBUG_LOCATION, calld->recv_im_ready,
grpc_error_set_int(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Failure that's not preventable.", &error, 1),
GRPC_ERROR_INT_GRPC_STATUS,
grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_PERMISSION_DENIED));
}

@ -36,6 +36,7 @@
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/channel/channel_stack_builder.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/surface/channel_init.h"
@ -427,7 +428,7 @@ static grpc_error_handle init_call_elem(
grpc_call_element* /*elem*/, const grpc_call_element_args* /*args*/) {
return grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("access denied"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_PERMISSION_DENIED);
grpc_core::StatusIntProperty::kRpcStatus, GRPC_STATUS_PERMISSION_DENIED);
}
static void destroy_call_elem(grpc_call_element* /*elem*/,
@ -439,7 +440,7 @@ static grpc_error_handle init_channel_elem(
if (g_channel_filter_init_failure) {
return grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test channel filter init error"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_INVALID_ARGUMENT);
grpc_core::StatusIntProperty::kRpcStatus, GRPC_STATUS_INVALID_ARGUMENT);
}
return absl::OkStatus();
}

@ -41,6 +41,7 @@
#include "src/core/lib/channel/channel_stack_builder.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/call_combiner.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/error.h"
@ -275,7 +276,8 @@ class FailSendOpsFilter {
batch,
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"FailSendOpsFilter failing batch"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_ABORTED),
grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_ABORTED),
calld->call_combiner_);
return;
}

@ -38,6 +38,7 @@
#include "src/core/lib/channel/channel_stack_builder.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/call_combiner.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/error.h"
@ -305,7 +306,8 @@ class FailFirstSendOpFilter {
batch,
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"FailFirstSendOpFilter failing batch"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_ABORTED),
grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_ABORTED),
calld->call_combiner_);
return;
}

@ -37,6 +37,7 @@
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/surface/channel_init.h"
@ -315,7 +316,8 @@ class InjectStatusFilter {
DEBUG_LOCATION, calld->original_recv_trailing_metadata_ready_,
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("injected error"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_INVALID_ARGUMENT));
grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_INVALID_ARGUMENT));
}
grpc_closure recv_trailing_metadata_ready_;

@ -38,6 +38,7 @@
#include "src/core/lib/channel/channel_stack_builder.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/call_combiner.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/error.h"
@ -320,7 +321,8 @@ class FailFirstCallFilter {
batch,
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"FailFirstCallFilter failing batch"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_ABORTED),
grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_ABORTED),
calld->call_combiner_);
return;
}

@ -35,6 +35,7 @@
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/channel/channel_stack_builder.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/call_combiner.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/error.h"
@ -311,7 +312,7 @@ class FailFirstCallFilter {
batch,
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"FailFirstCallFilter failing batch"),
GRPC_ERROR_INT_GRPC_STATUS,
grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_UNAVAILABLE),
calld->call_combiner_);
return;

@ -35,6 +35,7 @@
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/channel/channel_stack_builder.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/call_combiner.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/error.h"
@ -310,7 +311,7 @@ class FailFirstTenCallsFilter {
batch,
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"FailFirstTenCallsFilter failing batch"),
GRPC_ERROR_INT_GRPC_STATUS,
grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_UNAVAILABLE),
calld->call_combiner_);
return;

@ -33,21 +33,28 @@ TEST(ErrorTest, SetGetInt) {
EXPECT_NE(error, absl::OkStatus());
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));
// grpc_core::StatusIntProperty::kFileLine is for debug only
EXPECT_TRUE(
grpc_error_get_int(error, grpc_core::StatusIntProperty::kFileLine, &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));
EXPECT_TRUE(
!grpc_error_get_int(error, grpc_core::StatusIntProperty::kErrorNo, &i));
EXPECT_TRUE(
!grpc_error_get_int(error, grpc_core::StatusIntProperty::kSize, &i));
intptr_t errnumber = 314;
error = grpc_error_set_int(error, GRPC_ERROR_INT_ERRNO, errnumber);
EXPECT_TRUE(grpc_error_get_int(error, GRPC_ERROR_INT_ERRNO, &i));
error = grpc_error_set_int(error, grpc_core::StatusIntProperty::kErrorNo,
errnumber);
EXPECT_TRUE(
grpc_error_get_int(error, grpc_core::StatusIntProperty::kErrorNo, &i));
EXPECT_EQ(i, errnumber);
intptr_t http = 2;
error = grpc_error_set_int(error, GRPC_ERROR_INT_HTTP2_ERROR, http);
EXPECT_TRUE(grpc_error_get_int(error, GRPC_ERROR_INT_HTTP2_ERROR, &i));
error = grpc_error_set_int(error, grpc_core::StatusIntProperty::kHttp2Error,
http);
EXPECT_TRUE(
grpc_error_get_int(error, grpc_core::StatusIntProperty::kHttp2Error, &i));
EXPECT_EQ(i, http);
}
@ -55,22 +62,27 @@ TEST(ErrorTest, SetGetStr) {
grpc_error_handle error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test");
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));
EXPECT_TRUE(
!grpc_error_get_str(error, grpc_core::StatusStrProperty::kSyscall, &str));
EXPECT_TRUE(!grpc_error_get_str(
error, grpc_core::StatusStrProperty::kTsiError, &str));
#ifndef NDEBUG
// GRPC_ERROR_STR_FILE is for debug only
EXPECT_TRUE(grpc_error_get_str(error, GRPC_ERROR_STR_FILE, &str));
// grpc_core::StatusStrProperty::kFile is for debug only
EXPECT_TRUE(
grpc_error_get_str(error, grpc_core::StatusStrProperty::kFile, &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_TRUE(grpc_error_get_str(
error, grpc_core::StatusStrProperty::kDescription, &str));
EXPECT_EQ(str, "Test");
error =
grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, "longer message");
EXPECT_TRUE(grpc_error_get_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, &str));
error = grpc_error_set_str(error, grpc_core::StatusStrProperty::kGrpcMessage,
"longer message");
EXPECT_TRUE(grpc_error_get_str(
error, grpc_core::StatusStrProperty::kGrpcMessage, &str));
EXPECT_EQ(str, "longer message");
}
@ -78,28 +90,32 @@ TEST(ErrorTest, CopyAndUnRef) {
// error1 has one ref
grpc_error_handle error1 =
grpc_error_set_str(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test"),
GRPC_ERROR_STR_GRPC_MESSAGE, "message");
grpc_core::StatusStrProperty::kGrpcMessage, "message");
std::string str;
EXPECT_TRUE(grpc_error_get_str(error1, GRPC_ERROR_STR_GRPC_MESSAGE, &str));
EXPECT_TRUE(grpc_error_get_str(
error1, grpc_core::StatusStrProperty::kGrpcMessage, &str));
EXPECT_EQ(str, "message");
// this gives error3 a ref to the new error, and decrements error1 to one ref
grpc_error_handle error3 =
grpc_error_set_str(error1, GRPC_ERROR_STR_SYSCALL, "syscall");
grpc_error_handle error3 = grpc_error_set_str(
error1, grpc_core::StatusStrProperty::kSyscall, "syscall");
EXPECT_NE(error3, error1); // should not be the same because of extra ref
EXPECT_TRUE(grpc_error_get_str(error3, GRPC_ERROR_STR_GRPC_MESSAGE, &str));
EXPECT_TRUE(grpc_error_get_str(
error3, grpc_core::StatusStrProperty::kGrpcMessage, &str));
EXPECT_EQ(str, "message");
// error 1 should not have a syscall but 3 should
EXPECT_TRUE(!grpc_error_get_str(error1, GRPC_ERROR_STR_SYSCALL, &str));
EXPECT_TRUE(grpc_error_get_str(error3, GRPC_ERROR_STR_SYSCALL, &str));
EXPECT_TRUE(!grpc_error_get_str(
error1, grpc_core::StatusStrProperty::kSyscall, &str));
EXPECT_TRUE(
grpc_error_get_str(error3, grpc_core::StatusStrProperty::kSyscall, &str));
EXPECT_EQ(str, "syscall");
}
TEST(ErrorTest, CreateReferencing) {
grpc_error_handle child =
grpc_error_set_str(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Child"),
GRPC_ERROR_STR_GRPC_MESSAGE, "message");
grpc_core::StatusStrProperty::kGrpcMessage, "message");
grpc_error_handle parent =
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Parent", &child, 1);
EXPECT_NE(parent, absl::OkStatus());
@ -109,13 +125,13 @@ TEST(ErrorTest, CreateReferencingMany) {
grpc_error_handle children[3];
children[0] =
grpc_error_set_str(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Child1"),
GRPC_ERROR_STR_GRPC_MESSAGE, "message");
grpc_core::StatusStrProperty::kGrpcMessage, "message");
children[1] =
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Child2"),
GRPC_ERROR_INT_HTTP2_ERROR, 5);
children[2] =
grpc_error_set_str(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Child3"),
GRPC_ERROR_STR_GRPC_MESSAGE, "message 3");
grpc_core::StatusIntProperty::kHttp2Error, 5);
children[2] = grpc_error_set_str(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Child3"),
grpc_core::StatusStrProperty::kGrpcMessage, "message 3");
grpc_error_handle parent =
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Parent", children, 3);
@ -126,11 +142,12 @@ TEST(ErrorTest, CreateReferencingMany) {
}
TEST(ErrorTest, PrintErrorString) {
grpc_error_handle error =
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNIMPLEMENTED);
error = grpc_error_set_int(error, GRPC_ERROR_INT_SIZE, 666);
error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, "message");
grpc_error_handle error = grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"),
grpc_core::StatusIntProperty::kRpcStatus, GRPC_STATUS_UNIMPLEMENTED);
error = grpc_error_set_int(error, grpc_core::StatusIntProperty::kSize, 666);
error = grpc_error_set_str(error, grpc_core::StatusStrProperty::kGrpcMessage,
"message");
// gpr_log(GPR_DEBUG, "%s", grpc_error_std_string(error).c_str());
}
@ -138,12 +155,14 @@ TEST(ErrorTest, PrintErrorStringReference) {
grpc_error_handle children[2];
children[0] = grpc_error_set_str(
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("1"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNIMPLEMENTED),
GRPC_ERROR_STR_GRPC_MESSAGE, "message for child 1");
grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_UNIMPLEMENTED),
grpc_core::StatusStrProperty::kGrpcMessage, "message for child 1");
children[1] = grpc_error_set_str(
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("2sd"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_INTERNAL),
GRPC_ERROR_STR_GRPC_MESSAGE, "message for child 2");
grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_INTERNAL),
grpc_core::StatusStrProperty::kGrpcMessage, "message for child 2");
grpc_error_handle parent =
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Parent", children, 2);
@ -158,11 +177,13 @@ TEST(ErrorTest, TestOsError) {
grpc_error_handle error = GRPC_OS_ERROR(fake_errno, syscall);
intptr_t i = 0;
EXPECT_TRUE(grpc_error_get_int(error, GRPC_ERROR_INT_ERRNO, &i));
EXPECT_TRUE(
grpc_error_get_int(error, grpc_core::StatusIntProperty::kErrorNo, &i));
EXPECT_EQ(i, fake_errno);
std::string str;
EXPECT_TRUE(grpc_error_get_str(error, GRPC_ERROR_STR_SYSCALL, &str));
EXPECT_TRUE(
grpc_error_get_str(error, grpc_core::StatusStrProperty::kSyscall, &str));
EXPECT_EQ(str, syscall);
}

@ -247,7 +247,8 @@ TEST(GrpcAwsRequestSignerTest, InvalidUrl) {
"token", "POST", "invalid_url",
"us-east-1", "", {}, &error);
std::string actual_error_description;
GPR_ASSERT(grpc_error_get_str(error, GRPC_ERROR_STR_DESCRIPTION,
GPR_ASSERT(grpc_error_get_str(error,
grpc_core::StatusStrProperty::kDescription,
&actual_error_description));
EXPECT_EQ(actual_error_description, "Invalid Aws request url.");
}
@ -259,7 +260,8 @@ TEST(GrpcAwsRequestSignerTest, DuplicateRequestDate) {
"us-east-1", "", {{"date", kBotoTestDate}, {"x-amz-date", kAmzTestDate}},
&error);
std::string actual_error_description;
GPR_ASSERT(grpc_error_get_str(error, GRPC_ERROR_STR_DESCRIPTION,
GPR_ASSERT(grpc_error_get_str(error,
grpc_core::StatusStrProperty::kDescription,
&actual_error_description));
EXPECT_EQ(actual_error_description,
"Only one of {date, x-amz-date} can be specified, not both.");

@ -522,11 +522,11 @@ class RequestMetadataState : public RefCounted<RequestMetadataState> {
GPR_ASSERT(error.ok());
} else {
std::string expected_error;
GPR_ASSERT(grpc_error_get_str(expected_error_, GRPC_ERROR_STR_DESCRIPTION,
&expected_error));
GPR_ASSERT(grpc_error_get_str(
expected_error_, StatusStrProperty::kDescription, &expected_error));
std::string actual_error;
GPR_ASSERT(
grpc_error_get_str(error, GRPC_ERROR_STR_DESCRIPTION, &actual_error));
GPR_ASSERT(grpc_error_get_str(error, StatusStrProperty::kDescription,
&actual_error));
GPR_ASSERT(expected_error == actual_error);
}
md_.Remove(HttpAuthorityMetadata());
@ -2735,8 +2735,8 @@ TEST(CredentialsTest,
auto creds = UrlExternalAccountCredentials::Create(options, {}, &error);
GPR_ASSERT(creds == nullptr);
std::string actual_error;
GPR_ASSERT(
grpc_error_get_str(error, GRPC_ERROR_STR_DESCRIPTION, &actual_error));
GPR_ASSERT(grpc_error_get_str(error, StatusStrProperty::kDescription,
&actual_error));
GPR_ASSERT(absl::StartsWith(actual_error, "Invalid credential source url."));
}
@ -3282,8 +3282,8 @@ TEST(CredentialsTest,
GPR_ASSERT(creds == nullptr);
std::string expected_error = "environment_id does not match.";
std::string actual_error;
GPR_ASSERT(
grpc_error_get_str(error, GRPC_ERROR_STR_DESCRIPTION, &actual_error));
GPR_ASSERT(grpc_error_get_str(error, StatusStrProperty::kDescription,
&actual_error));
GPR_ASSERT(expected_error == actual_error);
}

@ -137,11 +137,11 @@ class GrpcTlsCertificateDistributorTest : public ::testing::Test {
std::string identity_error_str;
if (!root_cert_error.ok()) {
GPR_ASSERT(grpc_error_get_str(
root_cert_error, GRPC_ERROR_STR_DESCRIPTION, &root_error_str));
root_cert_error, StatusStrProperty::kDescription, &root_error_str));
}
if (!identity_cert_error.ok()) {
GPR_ASSERT(grpc_error_get_str(identity_cert_error,
GRPC_ERROR_STR_DESCRIPTION,
StatusStrProperty::kDescription,
&identity_error_str));
}
state_->error_queue.emplace_back(std::move(root_error_str),

@ -139,11 +139,11 @@ class GrpcTlsCertificateProviderTest : public ::testing::Test {
std::string identity_error_str;
if (!root_cert_error.ok()) {
GPR_ASSERT(grpc_error_get_str(
root_cert_error, GRPC_ERROR_STR_DESCRIPTION, &root_error_str));
root_cert_error, StatusStrProperty::kDescription, &root_error_str));
}
if (!identity_cert_error.ok()) {
GPR_ASSERT(grpc_error_get_str(identity_cert_error,
GRPC_ERROR_STR_DESCRIPTION,
StatusStrProperty::kDescription,
&identity_error_str));
}
state_->error_queue.emplace_back(std::move(root_error_str),

@ -104,7 +104,7 @@ class TlsSecurityConnectorTest : public ::testing::Test {
static std::string GetErrorMsg(grpc_error_handle error) {
std::string error_str;
GPR_ASSERT(
grpc_error_get_str(error, GRPC_ERROR_STR_DESCRIPTION, &error_str));
grpc_error_get_str(error, StatusStrProperty::kDescription, &error_str));
return error_str;
}

@ -23,6 +23,7 @@
#include "absl/status/status.h"
#include "gtest/gtest.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/error.h"
#include "test/core/util/test_config.h"
@ -39,9 +40,9 @@ TEST(ErrorUtilsTest, GetErrorGetStatusNone) {
}
TEST(ErrorUtilsTest, GetErrorGetStatusFlat) {
grpc_error_handle error =
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Msg"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_CANCELLED);
grpc_error_handle error = grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Msg"),
grpc_core::StatusIntProperty::kRpcStatus, GRPC_STATUS_CANCELLED);
grpc_status_code code;
std::string message;
grpc_error_get_status(error, grpc_core::Timestamp(), &code, &message, nullptr,
@ -54,7 +55,7 @@ TEST(ErrorUtilsTest, GetErrorGetStatusChild) {
std::vector<grpc_error_handle> children = {
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Child1"),
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Child2"),
GRPC_ERROR_INT_GRPC_STATUS,
grpc_core::StatusIntProperty::kRpcStatus,
GRPC_STATUS_RESOURCE_EXHAUSTED),
};
grpc_error_handle error = GRPC_ERROR_CREATE_FROM_VECTOR("Parent", &children);
@ -104,11 +105,13 @@ TEST(ErrorUtilsTest, AbslUnavailableToGrpcError) {
absl_status_to_grpc_error(absl::UnavailableError("Making tea"));
// Status code checks
intptr_t code;
ASSERT_TRUE(grpc_error_get_int(error, GRPC_ERROR_INT_GRPC_STATUS, &code));
ASSERT_TRUE(grpc_error_get_int(
error, grpc_core::StatusIntProperty::kRpcStatus, &code));
ASSERT_EQ(static_cast<grpc_status_code>(code), GRPC_STATUS_UNAVAILABLE);
// Status message checks
std::string message;
ASSERT_TRUE(grpc_error_get_str(error, GRPC_ERROR_STR_DESCRIPTION, &message));
ASSERT_TRUE(grpc_error_get_str(
error, grpc_core::StatusStrProperty::kDescription, &message));
ASSERT_EQ(message, "Making tea");
}
@ -116,7 +119,7 @@ TEST(ErrorUtilsTest, GrpcErrorUnavailableToAbslStatus) {
grpc_error_handle error = grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"weighted_target: all children report state TRANSIENT_FAILURE"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
grpc_core::StatusIntProperty::kRpcStatus, GRPC_STATUS_UNAVAILABLE);
absl::Status status = grpc_error_to_absl_status(error);
ASSERT_TRUE(absl::IsUnavailable(status));
ASSERT_EQ(status.message(),

@ -1512,7 +1512,7 @@ TEST_P(End2endTest, ExpectErrorTest) {
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
// grpc_core::StatusIntProperty::kFileLine is for debug only
EXPECT_TRUE(absl::StrContains(context.debug_error_string(), "file"));
EXPECT_TRUE(absl::StrContains(context.debug_error_string(), "line"));
#endif

Loading…
Cancel
Save