status_helper.h
Go to the documentation of this file.
1 //
2 //
3 // Copyright 2021 the gRPC authors.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 //
18 
19 #ifndef GRPC_CORE_LIB_GPRPP_STATUS_HELPER_H
20 #define GRPC_CORE_LIB_GPRPP_STATUS_HELPER_H
21 
23 
24 #include <stdint.h>
25 
26 #include <string>
27 #include <vector>
28 
29 #include "absl/status/status.h"
30 #include "absl/strings/string_view.h"
31 #include "absl/time/time.h"
32 #include "absl/types/optional.h"
33 
35 
36 extern "C" {
37 struct google_rpc_Status;
38 struct upb_Arena;
39 }
40 
41 namespace grpc_core {
42 
44 // TODO(veblush): Use camel-case names once migration to absl::Status is done.
45 enum class StatusIntProperty {
47  kErrorNo,
49  kFileLine,
52  kStreamId,
54  // TODO(veblush): Remove this after grpc_error is replaced with absl::Status
55  kRpcStatus,
58  kOffset,
60  kIndex,
62  kSize,
66  kTsiCode,
68  kWsaError,
70  kFd,
79 };
80 
82 // TODO(veblush): Use camel-case names once migration to absl::Status is done.
83 enum class StatusStrProperty {
87  kFile,
89  kOsError,
91  kSyscall,
97  kRawBytes,
99  kTsiError,
101  kFilename,
103  kKey,
105  kValue,
106 };
107 
109 enum class StatusTimeProperty {
111  kCreated,
112 };
113 
116  absl::StatusCode code, absl::string_view msg, const DebugLocation& location,
117  std::vector<absl::Status> children) GRPC_MUST_USE_RESULT;
118 
121 
125 
129 
133 
136  absl::Time time);
137 
141 
144 
146 std::vector<absl::Status> StatusGetChildren(absl::Status status)
148 
155 
156 namespace internal {
157 
162 
166 
171 
174 
177 
180 
181 } // namespace internal
182 
183 } // namespace grpc_core
184 
185 #endif // GRPC_CORE_LIB_GPRPP_STATUS_HELPER_H
google_rpc_Status
struct google_rpc_Status google_rpc_Status
Definition: google/rpc/status.upb.h:24
grpc_core::internal::StatusFromProto
absl::Status StatusFromProto(google_rpc_Status *msg)
Definition: status_helper.cc:398
ptr
char * ptr
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:45
grpc_core::StatusIntProperty::kStreamId
@ kStreamId
grpc_core::StatusIntProperty::kFileLine
@ kFileLine
LINE from the call site creating the error
grpc_core::StatusIntProperty::kRpcStatus
@ kRpcStatus
grpc status code representing this error
grpc_core::StatusStrProperty::kRawBytes
@ kRawBytes
hex dump (or similar) with the data that generated this error
grpc_core::StatusGetChildren
std::vector< absl::Status > StatusGetChildren(absl::Status status)
Returns all children status from a status.
Definition: status_helper.cc:276
grpc_core::StatusIntProperty::kTsiCode
@ kTsiCode
TSI status code associated with the error.
absl::Time
Definition: third_party/abseil-cpp/absl/time/time.h:642
grpc_core
Definition: call_metric_recorder.h:31
grpc_core::StatusStrProperty::kFile
@ kFile
source file in which this error occurred
grpc_core::StatusAddChild
void StatusAddChild(absl::Status *status, absl::Status child)
Adds a child status to status.
Definition: status_helper.cc:256
grpc_core::StatusStrProperty::kOsError
@ kOsError
operating system description of this error
grpc_core::internal::StatusAllocHeapPtr
uintptr_t StatusAllocHeapPtr(absl::Status s)
Definition: status_helper.cc:421
grpc_core::StatusIntProperty::kOffset
@ kOffset
absl::string_view
Definition: abseil-cpp/absl/strings/string_view.h:167
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
grpc_core::StatusTimeProperty::kCreated
@ kCreated
timestamp of error creation
grpc_core::StatusSetTime
void StatusSetTime(absl::Status *status, StatusTimeProperty key, absl::Time time)
Sets the time property to the status.
Definition: status_helper.cc:227
grpc_core::StatusIntProperty::kLbPolicyDrop
@ kLbPolicyDrop
LB policy drop.
status
absl::Status status
Definition: rls.cc:251
grpc_core::StatusCreate
absl::Status StatusCreate(absl::StatusCode code, absl::string_view msg, const DebugLocation &location, std::vector< absl::Status > children)
Creates a status with given additional information.
Definition: status_helper.cc:168
grpc_core::StatusStrProperty::kTsiError
@ kTsiError
tsi error string associated with this error
grpc_core::StatusStrProperty::kSyscall
@ kSyscall
syscall that generated this error
grpc_core::StatusGetStr
absl::optional< std::string > StatusGetStr(const absl::Status &status, StatusStrProperty key)
Gets the str property from the status.
Definition: status_helper.cc:217
arena
grpc_core::ScopedArenaPtr arena
Definition: binder_transport_test.cc:237
grpc_core::StatusSetInt
void StatusSetInt(absl::Status *status, StatusIntProperty key, intptr_t value)
Sets the int property to the status.
Definition: status_helper.cc:187
grpc_core::StatusToString
std::string StatusToString(const absl::Status &status)
Definition: status_helper.cc:282
grpc_core::StatusStrProperty::kFilename
@ kFilename
filename that we were trying to read/write when this error occurred
grpc_core::internal::StatusGetFromHeapPtr
absl::Status StatusGetFromHeapPtr(uintptr_t ptr)
Get the status from a heap ptr.
Definition: status_helper.cc:432
absl::optional
Definition: abseil-cpp/absl/types/internal/optional.h:61
grpc_core::StatusIntProperty::kWsaError
@ kWsaError
WSAGetLastError() reported when this error occurred.
googletest-filter-unittest.child
child
Definition: bloaty/third_party/googletest/googletest/test/googletest-filter-unittest.py:62
intptr_t
_W64 signed int intptr_t
Definition: stdint-msvc2008.h:118
grpc_core::StatusSetStr
void StatusSetStr(absl::Status *status, StatusStrProperty key, absl::string_view value)
Sets the str property to the status.
Definition: status_helper.cc:212
grpc_core::StatusStrProperty::kDescription
@ kDescription
top-level textual description of this error
uintptr_t
_W64 unsigned int uintptr_t
Definition: stdint-msvc2008.h:119
grpc_core::internal::StatusFreeHeapPtr
void StatusFreeHeapPtr(uintptr_t ptr)
Frees the allocated status at heap ptr.
Definition: status_helper.cc:427
grpc_core::StatusIntProperty::ChannelConnectivityState
@ ChannelConnectivityState
channel connectivity state associated with the error
stdint.h
msg
std::string msg
Definition: client_interceptors_end2end_test.cc:372
grpc_core::StatusStrProperty::kValue
@ kValue
value associated with the error
grpc_core::StatusTimeProperty
StatusTimeProperty
This enum should have the same value of grpc_error_times.
Definition: status_helper.h:109
grpc_core::internal::StatusToProto
google_rpc_Status * StatusToProto(const absl::Status &status, upb_Arena *arena)
Definition: status_helper.cc:353
value
const char * value
Definition: hpack_parser_table.cc:165
grpc_core::StatusStrProperty::kGrpcMessage
@ kGrpcMessage
grpc status message associated with this error
debug_location.h
key
const char * key
Definition: hpack_parser_table.cc:164
GRPC_MUST_USE_RESULT
#define GRPC_MUST_USE_RESULT
Definition: impl/codegen/port_platform.h:584
grpc_core::StatusGetTime
absl::optional< absl::Time > StatusGetTime(const absl::Status &status, StatusTimeProperty key)
Gets the time property from the status.
Definition: status_helper.cc:235
absl::StatusCode
StatusCode
Definition: third_party/abseil-cpp/absl/status/status.h:92
grpc_core::StatusStrProperty::kKey
@ kKey
key associated with the error
absl::Status
Definition: third_party/abseil-cpp/absl/status/status.h:424
grpc_core::StatusIntProperty::kHttpStatus
@ kHttpStatus
HTTP status (i.e. 404)
grpc_core::internal::StatusMoveFromHeapPtr
absl::Status StatusMoveFromHeapPtr(uintptr_t ptr)
Move the status from a heap ptr. (GetFrom & FreeHeap)
Definition: status_helper.cc:440
grpc_core::StatusIntProperty::kSize
@ kSize
context sensitive size associated with the error
grpc_core::StatusStrProperty
StatusStrProperty
This enum should have the same value of grpc_error_strs.
Definition: status_helper.h:83
internal
Definition: benchmark/test/output_test_helper.cc:20
grpc_core::StatusGetInt
absl::optional< intptr_t > StatusGetInt(const absl::Status &status, StatusIntProperty key)
Gets the int property from the status.
Definition: status_helper.cc:192
code
Definition: bloaty/third_party/zlib/contrib/infback9/inftree9.h:24
grpc_core::StatusIntProperty::kOccurredDuringWrite
@ kOccurredDuringWrite
chttp2: did the error occur while a write was in progress
grpc_core::StatusIntProperty
StatusIntProperty
This enum should have the same value of grpc_error_ints.
Definition: status_helper.h:45
grpc_core::StatusIntProperty::kHttp2Error
@ kHttp2Error
http2 error code associated with the error (see the HTTP2 RFC)
children
std::map< std::string, Node * > children
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/field_mask_util.cc:257
upb_Arena
Definition: upb_internal.h:36
grpc_core::StatusIntProperty::kFd
@ kFd
File descriptor associated with this error.
grpc_core::StatusIntProperty::kIndex
@ kIndex
context sensitive index associated with the error
grpc_core::StatusIntProperty::kErrorNo
@ kErrorNo
'errno' from the operating system
grpc_core::StatusStrProperty::kTargetAddress
@ kTargetAddress
peer that we were trying to communicate when this error occurred
port_platform.h


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:17