19 #ifndef GRPC_CORE_LIB_IOMGR_ERROR_H
20 #define GRPC_CORE_LIB_IOMGR_ERROR_H
35 #include "absl/status/status.h"
41 #ifdef GRPC_ERROR_IS_ABSEIL_STATUS
155 #ifdef GRPC_ERROR_IS_ABSEIL_STATUS
157 #define GRPC_ERROR_NONE absl::OkStatus()
158 #define GRPC_ERROR_OOM absl::Status(absl::ResourceExhaustedError)
159 #define GRPC_ERROR_CANCELLED absl::CancelledError()
161 #define GRPC_ERROR_REF(err) (err)
162 #define GRPC_ERROR_UNREF(err)
164 #define GRPC_ERROR_CREATE_FROM_STATIC_STRING(desc) \
165 StatusCreate(absl::StatusCode::kUnknown, desc, DEBUG_LOCATION, {})
166 #define GRPC_ERROR_CREATE_FROM_COPIED_STRING(desc) \
167 StatusCreate(absl::StatusCode::kUnknown, desc, DEBUG_LOCATION, {})
168 #define GRPC_ERROR_CREATE_FROM_STRING_VIEW(desc) \
169 StatusCreate(absl::StatusCode::kUnknown, desc, DEBUG_LOCATION, {})
173 size_t children_count,
178 #define GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(desc, errs, count) \
179 grpc_status_create(absl::StatusCode::kUnknown, desc, DEBUG_LOCATION, count, \
181 #define GRPC_ERROR_CREATE_REFERENCING_FROM_COPIED_STRING(desc, errs, count) \
182 grpc_status_create(absl::StatusCode::kUnknown, desc, DEBUG_LOCATION, count, \
187 template <
typename VectorType>
190 VectorType* error_list) {
192 if (error_list->size() != 0) {
194 error_list->size(), error_list->data());
200 #define GRPC_ERROR_CREATE_FROM_VECTOR(desc, error_list) \
201 grpc_status_create_from_vector(DEBUG_LOCATION, desc, error_list)
212 #define GRPC_OS_ERROR(err, call_name) \
213 grpc_assert_never_ok(grpc_os_error(DEBUG_LOCATION, err, call_name))
219 #define GRPC_WSA_ERROR(err, call_name) \
220 grpc_wsa_error(DEBUG_LOCATION, err, call_name)
228 #define GRPC_ERROR_NONE ((grpc_error_handle)NULL)
229 #define GRPC_ERROR_RESERVED_1 ((grpc_error_handle)1)
230 #define GRPC_ERROR_OOM ((grpc_error_handle)2)
231 #define GRPC_ERROR_RESERVED_2 ((grpc_error_handle)3)
232 #define GRPC_ERROR_CANCELLED ((grpc_error_handle)4)
233 #define GRPC_ERROR_SPECIAL_MAX GRPC_ERROR_CANCELLED
253 #define GRPC_ERROR_REF(err) grpc_error_ref(err, __FILE__, __LINE__)
254 #define GRPC_ERROR_UNREF(err) grpc_error_unref(err, __FILE__, __LINE__)
266 #define GRPC_ERROR_REF(err) grpc_error_ref(err)
267 #define GRPC_ERROR_UNREF(err) grpc_error_unref(err)
274 size_t num_referencing);
283 #define GRPC_ERROR_CREATE_FROM_STATIC_STRING(desc) \
284 grpc_error_create(__FILE__, __LINE__, grpc_slice_from_static_string(desc), \
286 #define GRPC_ERROR_CREATE_FROM_COPIED_STRING(desc) \
287 grpc_error_create(__FILE__, __LINE__, grpc_slice_from_copied_string(desc), \
289 #define GRPC_ERROR_CREATE_FROM_STRING_VIEW(desc) \
291 __FILE__, __LINE__, \
292 grpc_slice_from_copied_buffer((desc).data(), (desc).size()), NULL, 0)
296 #define GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(desc, errs, count) \
297 grpc_error_create(__FILE__, __LINE__, grpc_slice_from_static_string(desc), \
299 #define GRPC_ERROR_CREATE_REFERENCING_FROM_COPIED_STRING(desc, errs, count) \
300 grpc_error_create(__FILE__, __LINE__, grpc_slice_from_copied_string(desc), \
303 #define GRPC_ERROR_CREATE_FROM_VECTOR(desc, error_list) \
304 grpc_error_create_from_vector(__FILE__, __LINE__, desc, error_list)
308 template <
typename VectorType>
312 VectorType* error_list) {
314 if (error_list->size() != 0) {
316 error_list->
data(), error_list->size());
318 for (
size_t i = 0; i < error_list->size(); i++) {
335 #define GRPC_OS_ERROR(err, call_name) \
336 grpc_assert_never_ok(grpc_os_error(__FILE__, __LINE__, err, call_name))
340 #define GRPC_WSA_ERROR(err, call_name) \
341 grpc_wsa_error(__FILE__, __LINE__, err, call_name)
379 const char* file,
int line) {
384 #define GRPC_LOG_IF_ERROR(what, error) \
385 (grpc_log_if_error((what), (error), __FILE__, __LINE__))
Definition: debug_location.h:31
#define DEBUG_LOCATION
Definition: debug_location.h:41
grpc_error_times
Definition: error.h:138
@ GRPC_ERROR_TIME_MAX
Must always be last.
Definition: error.h:143
@ GRPC_ERROR_TIME_CREATED
timestamp of error creation
Definition: error.h:140
std::string grpc_error_std_string(grpc_error_handle error)
Definition: error.cc:879
bool grpc_log_error(const char *what, grpc_error_handle error, const char *file, int line)
Definition: error.cc:915
bool grpc_error_is_special(grpc_error_handle err)
Definition: error.h:235
grpc_error_handle grpc_os_error(const char *file, int line, int err, const char *call_name) GRPC_MUST_USE_RESULT
Definition: error.cc:883
grpc_error * grpc_error_handle
Definition: error.h:48
grpc_error_handle grpc_error_ref(grpc_error_handle err, const char *file, int line)
Definition: error.h:243
grpc_error_ints
Definition: error.h:52
@ GRPC_ERROR_INT_HTTP_STATUS
HTTP status (i.e. 404)
Definition: error.h:86
@ GRPC_ERROR_INT_INDEX
context sensitive index associated with the error
Definition: error.h:71
@ GRPC_ERROR_INT_FD
File descriptor associated with this error.
Definition: error.h:84
@ GRPC_ERROR_INT_STREAM_ID
stream identifier: for errors that are associated with an individual wire stream
Definition: error.h:61
@ GRPC_ERROR_INT_HTTP2_ERROR
http2 error code associated with the error (see the HTTP2 RFC)
Definition: error.h:75
@ GRPC_ERROR_INT_CHANNEL_CONNECTIVITY_STATE
channel connectivity state associated with the error
Definition: error.h:92
@ GRPC_ERROR_INT_WSA_ERROR
WSAGetLastError() reported when this error occurred.
Definition: error.h:81
@ GRPC_ERROR_INT_MAX
Must always be last.
Definition: error.h:99
@ GRPC_ERROR_INT_GRPC_STATUS
grpc status code representing this error
Definition: error.h:64
@ GRPC_ERROR_INT_FILE_LINE
LINE from the call site creating the error
Definition: error.h:57
@ GRPC_ERROR_INT_LB_POLICY_DROP
LB policy drop.
Definition: error.h:95
@ GRPC_ERROR_INT_TSI_CODE
TSI status code associated with the error.
Definition: error.h:78
@ GRPC_ERROR_INT_SIZE
context sensitive size associated with the error
Definition: error.h:73
@ GRPC_ERROR_INT_OFFSET
offset into some binary blob (usually represented by GRPC_ERROR_STR_RAW_BYTES) where the error occurr...
Definition: error.h:68
@ GRPC_ERROR_INT_OCCURRED_DURING_WRITE
chttp2: did the error occur while a write was in progress
Definition: error.h:89
@ GRPC_ERROR_INT_ERRNO
'errno' from the operating system
Definition: error.h:54
#define GRPC_ERROR_NONE
The following "special" errors can be propagated without allocating memory.
Definition: error.h:228
void grpc_error_unref(grpc_error_handle err, const char *file, int line)
Definition: error.h:248
grpc_error_handle grpc_error_do_ref(grpc_error_handle err, const char *file, int line)
Definition: error.cc:232
bool grpc_error_get_str(grpc_error_handle error, grpc_error_strs which, grpc_slice *s)
Returns false if the specified string is not set.
Definition: error.cc:590
void grpc_error_do_unref(grpc_error_handle err, const char *file, int line)
Definition: error.cc:281
void grpc_enable_error_creation()
Definition: error.cc:50
bool grpc_log_if_error(const char *what, grpc_error_handle error, const char *file, int line)
Definition: error.h:378
grpc_error_handle grpc_error_add_child(grpc_error_handle src, grpc_error_handle child) GRPC_MUST_USE_RESULT
Add a child error: an error that is believed to have contributed to this error occurring.
Definition: error.cc:611
grpc_error_strs
Definition: error.h:102
@ GRPC_ERROR_STR_TSI_ERROR
tsi error string associated with this error
Definition: error.h:124
@ GRPC_ERROR_STR_DESCRIPTION
top-level textual description of this error
Definition: error.h:104
@ GRPC_ERROR_STR_RAW_BYTES
hex dump (or similar) with the data that generated this error
Definition: error.h:121
@ GRPC_ERROR_STR_TARGET_ADDRESS
peer that we were trying to communicate when this error occurred
Definition: error.h:115
@ GRPC_ERROR_STR_GRPC_MESSAGE
grpc status message associated with this error
Definition: error.h:118
@ GRPC_ERROR_STR_OS_ERROR
operating system description of this error
Definition: error.h:109
@ GRPC_ERROR_STR_FILENAME
filename that we were trying to read/write when this error occurred
Definition: error.h:127
@ GRPC_ERROR_STR_MAX
Must always be last.
Definition: error.h:135
@ GRPC_ERROR_STR_FILE
source file in which this error occurred
Definition: error.h:107
@ GRPC_ERROR_STR_KEY
key associated with the error
Definition: error.h:130
@ GRPC_ERROR_STR_SYSCALL
syscall that generated this error
Definition: error.h:112
@ GRPC_ERROR_STR_VALUE
value associated with the error
Definition: error.h:132
bool grpc_error_get_int(grpc_error_handle error, grpc_error_ints which, intptr_t *p)
It is an error to pass nullptr as p.
Definition: error.cc:565
grpc_error_handle grpc_wsa_error(const char *file, int line, int err, const char *call_name) GRPC_MUST_USE_RESULT
#define GRPC_ERROR_UNREF(err)
Definition: error.h:254
grpc_error_handle grpc_assert_never_ok(grpc_error_handle error)
Definition: error.h:329
grpc_error_handle grpc_error_set_int(grpc_error_handle src, grpc_error_ints which, intptr_t value) GRPC_MUST_USE_RESULT
Definition: error.cc:542
const char * grpc_error_string(grpc_error_handle error)
Definition: error.cc:844
#define GRPC_ERROR_SPECIAL_MAX
Definition: error.h:233
grpc_error_handle grpc_error_set_str(grpc_error_handle src, grpc_error_strs which, const grpc_slice &str) GRPC_MUST_USE_RESULT
This call takes ownership of the slice; the error is responsible for eventually unref-ing it.
Definition: error.cc:581
void grpc_disable_error_creation()
Definition: error.cc:46
grpc_error_handle grpc_error_create(const char *file, int line, const grpc_slice &desc, grpc_error_handle *referencing, size_t num_referencing)
Create an error - but use GRPC_ERROR_CREATE instead.
Definition: error.cc:416
GPRAPI grpc_slice grpc_slice_from_static_string(const char *source)
Create a slice pointing to constant memory.
Definition: slice.cc:108
#define GPR_ASSERT(x)
abort() the process if x is zero, having written a line to the log.
Definition: log.h:92
grpc_error_handle error
Definition: lame_client.cc:54
::google::protobuf::util::Status Status
Definition: config_protobuf.h:91
@ kFile
source file in which this error occurred
@ kKey
key associated with the error
@ kFilename
filename that we were trying to read/write when this error occurred
@ kDescription
top-level textual description of this error
@ kGrpcMessage
grpc status message associated with this error
@ kValue
value associated with the error
@ kRawBytes
hex dump (or similar) with the data that generated this error
@ kSyscall
syscall that generated this error
@ kOsError
operating system description of this error
@ kTargetAddress
peer that we were trying to communicate when this error occurred
@ kTsiError
tsi error string associated with this error
@ kLbPolicyDrop
LB policy drop.
@ kOffset
offset into some binary blob (usually represented by RAW_BYTES) where the error occurred
@ kStreamId
stream identifier: for errors that are associated with an individual wire stream
@ ChannelConnectivityState
channel connectivity state associated with the error
@ kSize
context sensitive size associated with the error
@ kHttp2Error
http2 error code associated with the error (see the HTTP2 RFC)
@ kHttpStatus
HTTP status (i.e. 404)
@ kFileLine
LINE from the call site creating the error
@ kErrorNo
'errno' from the operating system
@ kFd
File descriptor associated with this error.
@ kWsaError
WSAGetLastError() reported when this error occurred.
@ kIndex
context sensitive index associated with the error
@ kOccurredDuringWrite
chttp2: did the error occur while a write was in progress
@ kTsiCode
TSI status code associated with the error.
@ kRpcStatus
grpc status code representing this error
StatusCode
Definition: status_code_enum.h:24
Definition: error_internal.h:41
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1].
Definition: slice.h:60
union grpc_slice::grpc_slice_data data