Go to the documentation of this file.
19 #ifndef GRPC_CORE_LIB_IOMGR_ERROR_H
20 #define GRPC_CORE_LIB_IOMGR_ERROR_H
27 #include "absl/status/status.h"
43 #ifdef GRPC_ERROR_IS_ABSEIL_STATUS
47 #else // GRPC_ERROR_IS_ABSEIL_STATUS
52 #endif // 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) (void)(err)
164 #define GRPC_ERROR_IS_NONE(err) (err).ok()
166 #define GRPC_ERROR_CREATE_FROM_STATIC_STRING(desc) \
167 StatusCreate(absl::StatusCode::kUnknown, desc, DEBUG_LOCATION, {})
168 #define GRPC_ERROR_CREATE_FROM_COPIED_STRING(desc) \
169 StatusCreate(absl::StatusCode::kUnknown, desc, DEBUG_LOCATION, {})
170 #define GRPC_ERROR_CREATE_FROM_CPP_STRING(desc) \
171 StatusCreate(absl::StatusCode::kUnknown, desc, DEBUG_LOCATION, {})
172 #define GRPC_ERROR_CREATE_FROM_STRING_VIEW(desc) \
173 StatusCreate(absl::StatusCode::kUnknown, desc, DEBUG_LOCATION, {})
177 size_t children_count,
182 #define GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(desc, errs, count) \
183 grpc_status_create(absl::StatusCode::kUnknown, desc, DEBUG_LOCATION, count, \
185 #define GRPC_ERROR_CREATE_REFERENCING_FROM_COPIED_STRING(desc, errs, count) \
186 grpc_status_create(absl::StatusCode::kUnknown, desc, DEBUG_LOCATION, count, \
191 template <
typename VectorType>
194 VectorType* error_list) {
196 if (error_list->size() != 0) {
198 error_list->size(), error_list->data());
204 #define GRPC_ERROR_CREATE_FROM_VECTOR(desc, error_list) \
205 grpc_status_create_from_vector(DEBUG_LOCATION, desc, error_list)
206 #define GRPC_ERROR_CREATE_FROM_VECTOR_AND_CPP_STRING(desc, error_list) \
207 grpc_status_create_from_vector(DEBUG_LOCATION, desc, error_list)
218 #define GRPC_OS_ERROR(err, call_name) \
219 grpc_assert_never_ok(grpc_os_error(DEBUG_LOCATION, err, call_name))
225 #define GRPC_WSA_ERROR(err, call_name) \
226 grpc_wsa_error(DEBUG_LOCATION, err, call_name)
228 #else // GRPC_ERROR_IS_ABSEIL_STATUS
234 #define GRPC_ERROR_NONE ((grpc_error_handle)NULL)
235 #define GRPC_ERROR_RESERVED_1 ((grpc_error_handle)1)
236 #define GRPC_ERROR_OOM ((grpc_error_handle)2)
237 #define GRPC_ERROR_RESERVED_2 ((grpc_error_handle)3)
238 #define GRPC_ERROR_CANCELLED ((grpc_error_handle)4)
239 #define GRPC_ERROR_SPECIAL_MAX GRPC_ERROR_CANCELLED
241 #define GRPC_ERROR_IS_NONE(err) ((err) == GRPC_ERROR_NONE)
261 #define GRPC_ERROR_REF(err) grpc_error_ref(err, __FILE__, __LINE__)
262 #define GRPC_ERROR_UNREF(err) grpc_error_unref(err, __FILE__, __LINE__)
274 #define GRPC_ERROR_REF(err) grpc_error_ref(err)
275 #define GRPC_ERROR_UNREF(err) grpc_error_unref(err)
282 size_t num_referencing);
291 #define GRPC_ERROR_CREATE_FROM_STATIC_STRING(desc) \
292 grpc_error_create(__FILE__, __LINE__, grpc_slice_from_static_string(desc), \
294 #define GRPC_ERROR_CREATE_FROM_COPIED_STRING(desc) \
295 grpc_error_create(__FILE__, __LINE__, grpc_slice_from_copied_string(desc), \
297 #define GRPC_ERROR_CREATE_FROM_CPP_STRING(desc) \
298 grpc_error_create(__FILE__, __LINE__, grpc_slice_from_cpp_string(desc), \
300 #define GRPC_ERROR_CREATE_FROM_STRING_VIEW(desc) \
302 __FILE__, __LINE__, \
303 grpc_slice_from_copied_buffer((desc).data(), (desc).size()), NULL, 0)
307 #define GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(desc, errs, count) \
308 grpc_error_create(__FILE__, __LINE__, grpc_slice_from_static_string(desc), \
310 #define GRPC_ERROR_CREATE_REFERENCING_FROM_COPIED_STRING(desc, errs, count) \
311 grpc_error_create(__FILE__, __LINE__, grpc_slice_from_copied_string(desc), \
314 #define GRPC_ERROR_CREATE_FROM_VECTOR(desc, error_list) \
315 grpc_error_create_from_vector( \
316 __FILE__, __LINE__, grpc_slice_from_static_string, desc, error_list)
317 #define GRPC_ERROR_CREATE_FROM_VECTOR_AND_CPP_STRING(desc, error_list) \
318 grpc_error_create_from_vector(__FILE__, __LINE__, \
319 grpc_slice_from_cpp_string, desc, error_list)
323 template <
typename VectorType,
typename StringType,
324 typename SliceFromStringFunction>
327 SliceFromStringFunction slice_from_string_function,
StringType desc,
328 VectorType* error_list) {
330 if (error_list->size() != 0) {
333 error_list->data(), error_list->size());
335 for (
size_t i = 0;
i < error_list->size();
i++) {
352 #define GRPC_OS_ERROR(err, call_name) \
353 grpc_assert_never_ok(grpc_os_error(__FILE__, __LINE__, err, call_name))
357 #define GRPC_WSA_ERROR(err, call_name) \
358 grpc_wsa_error(__FILE__, __LINE__, err, call_name)
360 #endif // GRPC_ERROR_IS_ABSEIL_STATUS
398 #define GRPC_LOG_IF_ERROR(what, error) \
399 (grpc_log_if_error((what), (error), __FILE__, __LINE__))
@ GRPC_ERROR_INT_WSA_ERROR
WSAGetLastError() reported when this error occurred.
@ GRPC_ERROR_STR_SYSCALL
syscall that generated this error
@ kFileLine
LINE from the call site creating the error
@ kRpcStatus
grpc status code representing this error
@ kRawBytes
hex dump (or similar) with the data that generated this error
@ GRPC_ERROR_STR_FILE
source file in which this error occurred
@ kTsiCode
TSI status code associated with the error.
bool grpc_error_get_str(grpc_error_handle error, grpc_error_strs which, std::string *str)
Returns false if the specified string is not set.
void grpc_disable_error_creation()
@ GRPC_ERROR_STR_MAX
Must always be last.
@ GRPC_ERROR_INT_LB_POLICY_DROP
LB policy drop.
@ kFile
source file in which this error occurred
@ GRPC_ERROR_INT_HTTP2_ERROR
http2 error code associated with the error (see the HTTP2 RFC)
@ kOsError
operating system description of this error
@ GRPC_ERROR_INT_INDEX
context sensitive index associated with the error
@ GRPC_ERROR_INT_CHANNEL_CONNECTIVITY_STATE
channel connectivity state associated with the error
@ kLbPolicyDrop
LB policy drop.
@ kTsiError
tsi error string associated with this error
@ GRPC_ERROR_INT_FD
File descriptor associated with this error.
@ kSyscall
syscall that generated this error
@ GRPC_ERROR_STR_RAW_BYTES
hex dump (or similar) with the data that generated this error
void set(grpc_error_handle error)
@ GRPC_ERROR_STR_DESCRIPTION
top-level textual description of this error
#define gpr_spinlock_lock(lock)
grpc_error_handle grpc_error_set_int(grpc_error_handle src, grpc_error_ints which, intptr_t value) GRPC_MUST_USE_RESULT
@ GRPC_ERROR_INT_TSI_CODE
TSI status code associated with the error.
@ GRPC_ERROR_STR_TARGET_ADDRESS
peer that we were trying to communicate when this error occurred
grpc_error_handle grpc_error_set_str(grpc_error_handle src, grpc_error_strs which, absl::string_view str) GRPC_MUST_USE_RESULT
@ GRPC_ERROR_TIME_CREATED
timestamp of error creation
bool grpc_log_error(const char *what, grpc_error_handle error, const char *file, int line)
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
void grpc_enable_error_creation()
grpc_error_handle grpc_wsa_error(const char *file, int line, int err, const char *call_name) GRPC_MUST_USE_RESULT
void grpc_error_unref(grpc_error_handle err, const char *file, int line)
#define GRPC_ERROR_SPECIAL_MAX
grpc_error_handle grpc_error_add_child(grpc_error_handle src, grpc_error_handle child) GRPC_MUST_USE_RESULT
@ kFilename
filename that we were trying to read/write when this error occurred
grpc_error * grpc_error_handle
@ GRPC_ERROR_INT_SIZE
context sensitive size associated with the error
void grpc_error_do_unref(grpc_error_handle err, const char *file, int line)
grpc_error_handle grpc_os_error(const char *file, int line, int err, const char *call_name) GRPC_MUST_USE_RESULT
@ GRPC_ERROR_INT_STREAM_ID
@ kWsaError
WSAGetLastError() reported when this error occurred.
#define gpr_spinlock_unlock(lock)
@ GRPC_ERROR_STR_GRPC_MESSAGE
grpc status message associated with this error
@ kDescription
top-level textual description of this error
@ GRPC_ERROR_INT_MAX
Must always be last.
grpc_error_handle grpc_error_ref(grpc_error_handle err, const char *file, int line)
@ ChannelConnectivityState
channel connectivity state associated with the error
@ kValue
value associated with the error
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.
@ GRPC_ERROR_STR_FILENAME
filename that we were trying to read/write when this error occurred
#define GPR_SPINLOCK_STATIC_INITIALIZER
@ GRPC_ERROR_STR_OS_ERROR
operating system description of this error
grpc_error_handle grpc_error_do_ref(grpc_error_handle err, const char *file, int line)
@ kGrpcMessage
grpc status message associated with this error
#define GRPC_ERROR_REF(err)
@ kKey
key associated with the error
bool grpc_error_get_int(grpc_error_handle error, grpc_error_ints which, intptr_t *p)
static grpc_error_handle grpc_error_create_from_vector(const char *file, int line, SliceFromStringFunction slice_from_string_function, StringType desc, VectorType *error_list)
UniquePtr< SSL_SESSION > ret
@ GRPC_ERROR_TIME_MAX
Must always be last.
@ GRPC_ERROR_INT_ERRNO
'errno' from the operating system
std::string grpc_error_std_string(grpc_error_handle error)
@ kHttpStatus
HTTP status (i.e. 404)
@ GRPC_ERROR_STR_TSI_ERROR
tsi error string associated with this error
@ GRPC_ERROR_STR_VALUE
value associated with the error
bool ok()
returns get() == GRPC_ERROR_NONE
@ GRPC_ERROR_STR_KEY
key associated with the error
bool grpc_log_if_error(const char *what, grpc_error_handle error, const char *file, int line)
#define GRPC_ERROR_UNREF(err)
@ kSize
context sensitive size associated with the error
bool grpc_error_is_special(grpc_error_handle err)
@ GRPC_ERROR_INT_FILE_LINE
LINE from the call site creating the error
AtomicError(grpc_error_handle error)
grpc_error_handle grpc_assert_never_ok(grpc_error_handle error)
@ GRPC_ERROR_INT_OCCURRED_DURING_WRITE
chttp2: did the error occur while a write was in progress
@ GRPC_ERROR_INT_HTTP_STATUS
HTTP status (i.e. 404)
@ kOccurredDuringWrite
chttp2: did the error occur while a write was in progress
@ kHttp2Error
http2 error code associated with the error (see the HTTP2 RFC)
std::map< std::string, Node * > children
@ kFd
File descriptor associated with this error.
@ kIndex
context sensitive index associated with the error
@ GRPC_ERROR_INT_GRPC_STATUS
grpc status code representing this error
@ kErrorNo
'errno' from the operating system
AtomicError & operator=(const AtomicError &)=delete
@ kTargetAddress
peer that we were trying to communicate when this error occurred
#define GRPC_ERROR_IS_NONE(err)
grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:59:15