Fix bugs in error (#27377)

reviewable/pr27416/r1
Esun Kim 3 years ago committed by GitHub
parent 1caff522e4
commit c80233a4ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/core/lib/gprpp/status_helper.cc
  2. 8
      src/core/lib/iomgr/error.cc
  3. 4
      src/core/lib/iomgr/error.h

@ -131,8 +131,9 @@ void EncodeUInt32ToBytes(uint32_t v, char* buf) {
}
uint32_t DecodeUInt32FromBytes(const char* buf) {
return buf[0] | (uint32_t(buf[1]) << 8) | (uint32_t(buf[2]) << 16) |
(uint32_t(buf[3]) << 24);
const unsigned char* ubuf = reinterpret_cast<const unsigned char*>(buf);
return ubuf[0] | (uint32_t(ubuf[1]) << 8) | (uint32_t(ubuf[2]) << 16) |
(uint32_t(ubuf[3]) << 24);
}
std::vector<absl::Status> ParseChildren(absl::Cord children) {

@ -65,7 +65,7 @@ absl::Status grpc_status_create(absl::StatusCode code, absl::string_view msg,
return s;
}
std::string grpc_error_std_string(const absl::Status& error) {
std::string grpc_error_std_string(absl::Status error) {
return grpc_core::StatusToString(error);
}
@ -87,9 +87,9 @@ absl::Status grpc_wsa_error(const grpc_core::DebugLocation& location, int err,
char* utf8_message = gpr_format_message(err);
absl::Status s =
StatusCreate(absl::StatusCode::kUnknown, "WSA Error", location, {});
StatusSetInt(&s, StatusIntProperty::WSA_ERROR, err);
StatusSetStr(&s, StatusStrProperty::OS_ERROR, utf8_message);
StatusSetStr(&s, StatusStrProperty::SYSCALL, call_name);
StatusSetInt(&s, grpc_core::StatusIntProperty::WSA_ERROR, err);
StatusSetStr(&s, grpc_core::StatusStrProperty::OS_ERROR, utf8_message);
StatusSetStr(&s, grpc_core::StatusStrProperty::SYSCALL, call_name);
}
#endif

@ -189,11 +189,11 @@ absl::Status grpc_status_create(absl::StatusCode code, absl::string_view msg,
// them. If the vector is empty, return GRPC_ERROR_NONE.
template <typename VectorType>
static absl::Status grpc_status_create_from_vector(
const grpc_core::DebugLocation& location, const char* desc,
const grpc_core::DebugLocation& location, absl::string_view desc,
VectorType* error_list) {
absl::Status error = GRPC_ERROR_NONE;
if (error_list->size() != 0) {
error = grpc_status_create(absl::StatusCode::kUnknown, desc, DEBUG_LOCATION,
error = grpc_status_create(absl::StatusCode::kUnknown, desc, location,
error_list->size(), error_list->data());
error_list->clear();
}

Loading…
Cancel
Save