Go to the documentation of this file.
14 #include "absl/status/status.h"
20 #include "absl/base/internal/raw_logging.h"
21 #include "absl/base/internal/strerror.h"
22 #include "absl/debugging/stacktrace.h"
23 #include "absl/debugging/symbolize.h"
24 #include "absl/status/status_payload_printer.h"
25 #include "absl/strings/escaping.h"
26 #include "absl/strings/str_cat.h"
27 #include "absl/strings/str_format.h"
28 #include "absl/strings/str_split.h"
42 return "INVALID_ARGUMENT";
44 return "DEADLINE_EXCEEDED";
48 return "ALREADY_EXISTS";
50 return "PERMISSION_DENIED";
52 return "UNAUTHENTICATED";
54 return "RESOURCE_EXHAUSTED";
56 return "FAILED_PRECONDITION";
60 return "OUT_OF_RANGE";
62 return "UNIMPLEMENTED";
78 namespace status_internal {
82 if (payloads ==
nullptr)
return -1;
84 for (
size_t i = 0;
i < payloads->
size(); ++
i) {
123 if (
index != -1)
return (*payloads)[
index].payload;
125 return absl::nullopt;
134 if (!
rep->payloads) {
135 rep->payloads = absl::make_unique<status_internal::Payloads>();
171 payloads->size() > 1 &&
reinterpret_cast<uintptr_t>(payloads) % 13 > 6;
175 (*payloads)[in_reverse ? payloads->size() - 1 -
index :
index];
178 visitor(
elem.type_url,
elem.payload);
198 #ifdef ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
204 return moved_from_string;
212 if (
r->ref.load(std::memory_order_acquire) == 1 ||
213 r->ref.fetch_sub(1, std::memory_order_acq_rel) - 1 == 0) {
219 : rep_(CodeToInlinedRep(
code)) {
230 return static_cast<int>(
rep->code);
248 if (
rep->ref.load(std::memory_order_acquire) != 1) {
249 std::unique_ptr<status_internal::Payloads> payloads;
251 payloads = absl::make_unique<status_internal::Payloads>(*
rep->payloads);
262 if (
a.message() !=
b.message())
return false;
263 if (
a.raw_code() !=
b.raw_code())
return false;
264 if (
a.GetPayloads() ==
b.GetPayloads())
return true;
268 a.GetPayloads() ?
a.GetPayloads() : &no_payloads;
270 b.GetPayloads() ?
b.GetPayloads() : &no_payloads;
271 if (larger_payloads->
size() < smaller_payloads->
size()) {
272 std::swap(larger_payloads, smaller_payloads);
274 if ((larger_payloads->
size() - smaller_payloads->
size()) > 1)
return false;
277 for (
const auto&
payload : *larger_payloads) {
280 for (
const auto& other_payload : *smaller_payloads) {
281 if (
payload.type_url == other_payload.type_url) {
282 if (
payload.payload != other_payload.payload) {
289 if (!
found)
return false;
452 switch (error_number) {
552 case EPROTONOSUPPORT:
553 #ifdef ESOCKTNOSUPPORT
554 case ESOCKTNOSUPPORT:
592 std::string MessageForErrnoToStatus(
int error_number,
601 MessageForErrnoToStatus(error_number,
message));
604 namespace status_internal {
Status InvalidArgumentError(absl::string_view message)
static void Unref(uintptr_t rep)
#define ABSL_RAW_CHECK(condition, message)
StatusPayloadPrinter GetStatusPayloadPrinter()
std::string ToStringSlow(StatusToStringMode mode) const
void StrAppend(std::string *dest, const AlphaNum &a)
std::string ToString(StatusToStringMode mode=StatusToStringMode::kDefault) const
Status AbortedError(absl::string_view message)
std::string StrCat(const AlphaNum &a, const AlphaNum &b)
bool IsDeadlineExceeded(const Status &status)
bool IsUnavailable(const Status &status)
Status ErrnoToStatus(int error_number, absl::string_view message)
ABSL_NAMESPACE_BEGIN std::ostream & operator<<(std::ostream &os, absl::LogSeverity s)
bool IsInternal(const Status &status)
Status CancelledError(absl::string_view message)
bool IsOutOfRange(const Status &status)
ABSL_NAMESPACE_BEGIN std::string StatusCodeToString(StatusCode code)
static bool EqualsSlow(const absl::Status &a, const absl::Status &b)
bool ErasePayload(absl::string_view type_url)
Status InternalError(absl::string_view message)
bool IsDataLoss(const Status &status)
const status_internal::Payloads * GetPayloads() const
#define ABSL_NAMESPACE_END
absl::StatusCode MapToLocalCode(int value)
iterator erase(const_iterator pos)
Status PermissionDeniedError(absl::string_view message)
Status UnauthenticatedError(absl::string_view message)
static void UnrefNonInlined(uintptr_t rep)
#define ABSL_NAMESPACE_BEGIN
std::string * MakeCheckFailString(const absl::Status *status, const char *prefix)
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
bool IsUnknown(const Status &status)
std::string StrError(int errnum)
Status FailedPreconditionError(absl::string_view message)
bool IsCancelled(const Status &status)
bool IsUnauthenticated(const Status &status)
Status UnknownError(absl::string_view message)
void SetPayload(absl::string_view type_url, absl::Cord payload)
absl::string_view message() const
static int FindPayloadIndexByUrl(const Payloads *payloads, absl::string_view type_url)
static constexpr const char kMovedFromString[]
bool IsNotFound(const Status &status)
void swap(Json::Value &a, Json::Value &b)
Specialize std::swap() for Json::Value.
Status DataLossError(absl::string_view message)
absl::optional< std::string >(*)(absl::string_view, const absl::Cord &) StatusPayloadPrinter
bool IsInvalidArgument(const Status &status)
Status OutOfRangeError(absl::string_view message)
size_type size() const noexcept
_W64 unsigned int uintptr_t
std::string CHexEscape(absl::string_view src)
void ForEachPayload(absl::FunctionRef< void(absl::string_view, const absl::Cord &)> visitor) const
static absl::StatusCode InlinedRepToCode(uintptr_t rep)
ABSL_NAMESPACE_BEGIN class ABSL_MUST_USE_RESULT Status
Status ResourceExhaustedError(absl::string_view message)
bool IsFailedPrecondition(const Status &status)
static bool IsInlined(uintptr_t rep)
bool IsResourceExhausted(const Status &status)
Status DeadlineExceededError(absl::string_view message)
static status_internal::StatusRep * RepToPointer(uintptr_t r)
static const char prefix[]
bool IsUnimplemented(const Status &status)
Status NotFoundError(absl::string_view message)
ABSL_MUST_USE_RESULT bool ok() const
Status UnavailableError(absl::string_view message)
static const std::string * MovedFromString()
static const std::string * EmptyString()
absl::optional< absl::Cord > GetPayload(absl::string_view type_url) const
Status UnimplementedError(absl::string_view message)
bool IsPermissionDenied(const Status &status)
static uintptr_t CodeToInlinedRep(absl::StatusCode code)
bool IsAborted(const Status &status)
absl::StatusCode code() const
bool IsAlreadyExists(const Status &status)
static uintptr_t PointerToRep(status_internal::StatusRep *r)
Status AlreadyExistsError(absl::string_view message)
StatusCode ErrnoToStatusCode(int error_number)
grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:17