summaryrefslogtreecommitdiff
path: root/absl/status/status.h
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2020-07-27 12:21:58 -0700
committerGravatar Mark Barolak <mbar@google.com>2020-07-27 15:43:11 -0400
commitd39fe6cd6f5eb72dc741f17d3a143a6a5a56538a (patch)
tree672d9eff428aeb3623eed12138e1b1a15fa0372a /absl/status/status.h
parent2c8a5b0d890cfbd2c1e70163e347f3e00b4ddb49 (diff)
Export of internal Abseil changes
-- 8726480d631a3736347f542dab5628d5e2ace3c1 by Mark Barolak <mbar@google.com>: Import of CCTZ from GitHub. PiperOrigin-RevId: 323414814 -- abc4a382a29fb857432e0e13a8c21ebe808f9828 by Abseil Team <absl-team@google.com>: Fix buffer overflow when the result of demangling doesn't fit. PiperOrigin-RevId: 323392968 -- 7ed3e514519a971322d0a3333c7e85ed1f2a5f71 by Gennadiy Rozental <rogeeff@google.com>: Move ABSL_DEPRECATED and ABSL_FALLTHROUGH_INTENDED from base.h into attribute.h. PiperOrigin-RevId: 323137526 -- fc0afdb0792d565065d25feb9680972218355f90 by Xiaoyi Zhang <zhangxy@google.com>: Add documentation for `absl::StatusCode`. PiperOrigin-RevId: 323065623 GitOrigin-RevId: 8726480d631a3736347f542dab5628d5e2ace3c1 Change-Id: I9d39650e49ff265cd2dafee302013694e97c813f
Diffstat (limited to 'absl/status/status.h')
-rw-r--r--absl/status/status.h113
1 files changed, 113 insertions, 0 deletions
diff --git a/absl/status/status.h b/absl/status/status.h
index 967e6064..42530621 100644
--- a/absl/status/status.h
+++ b/absl/status/status.h
@@ -24,24 +24,137 @@
namespace absl {
ABSL_NAMESPACE_BEGIN
+// Sometimes multiple error codes may apply. Services should return
+// the most specific error code that applies. For example, prefer
+// `kOutOfRange` over `kFailedPrecondition` if both codes apply.
+// Similarly prefer `kNotFound` or `kAlreadyExists` over `kFailedPrecondition`.
enum class StatusCode : int {
+ // Not an error; returned on success
kOk = 0,
+
+ // The operation was cancelled, typically by the caller.
kCancelled = 1,
+
+ // Unknown error. For example, errors raised by APIs that do not return
+ // enough error information may be converted to this error.
kUnknown = 2,
+
+ // The client specified an invalid argument. Note that this differs
+ // from `kFailedPrecondition`. `kInvalidArgument` indicates arguments
+ // that are problematic regardless of the state of the system
+ // (such as a malformed file name).
kInvalidArgument = 3,
+
+ // The deadline expired before the operation could complete. For operations
+ // that change the state of the system, this error may be returned
+ // even if the operation has completed successfully. For example, a
+ // successful response from a server could have been delayed long
+ // enough for the deadline to expire.
kDeadlineExceeded = 4,
+
+ // Some requested entity (such as file or directory) was not found.
+ //
+ // Note to server developers: if a request is denied for an entire class
+ // of users, such as gradual feature rollout or undocumented whitelist,
+ // `kNotFound` may be used. If a request is denied for some users within
+ // a class of users, such as user-based access control, `kPermissionDenied`
+ // must be used.
kNotFound = 5,
+
+ // The entity that a client attempted to create (such as file or directory)
+ // already exists.
kAlreadyExists = 6,
+
+ // The caller does not have permission to execute the specified
+ // operation. `kPermissionDenied` must not be used for rejections
+ // caused by exhausting some resource (use `kResourceExhausted`
+ // instead for those errors). `kPermissionDenied` must not be
+ // used if the caller can not be identified (use `kUnauthenticated`
+ // instead for those errors). This error code does not imply the
+ // request is valid or the requested entity exists or satisfies
+ // other pre-conditions.
kPermissionDenied = 7,
+
+ // Some resource has been exhausted, perhaps a per-user quota, or
+ // perhaps the entire file system is out of space.
kResourceExhausted = 8,
+
+ // The operation was rejected because the system is not in a state
+ // required for the operation's execution. For example, the directory
+ // to be deleted is non-empty, an rmdir operation is applied to
+ // a non-directory, etc.
+ //
+ // A litmus test that may help a service implementer in deciding
+ // between `kFailedPrecondition`, `kAborted`, and `kUnavailable`:
+ // (a) Use `kUnavailable` if the client can retry just the failing call.
+ // (b) Use `kAborted` if the client should retry at a higher-level
+ // (such as when a client-specified test-and-set fails, indicating the
+ // client should restart a read-modify-write sequence).
+ // (c) Use `kFailedPrecondition` if the client should not retry until
+ // the system state has been explicitly fixed. For example, if an "rmdir"
+ // fails because the directory is non-empty, `kFailedPrecondition`
+ // should be returned since the client should not retry unless
+ // the files are deleted from the directory.
kFailedPrecondition = 9,
+
+ // The operation was aborted, typically due to a concurrency issue such as
+ // a sequencer check failure or transaction abort.
+ //
+ // See litmus test above for deciding between `kFailedPrecondition`,
+ // `kAborted`, and `kUnavailable`.
kAborted = 10,
+
+ // The operation was attempted past the valid range, such as seeking or
+ // reading past end-of-file.
+ //
+ // Unlike `kInvalidArgument`, this error indicates a problem that may
+ // be fixed if the system state changes. For example, a 32-bit file
+ // system will generate `kInvalidArgument` if asked to read at an
+ // offset that is not in the range [0,2^32-1], but it will generate
+ // `kOutOfRange` if asked to read from an offset past the current
+ // file size.
+ //
+ // There is a fair bit of overlap between `kFailedPrecondition` and
+ // `kOutOfRange`. We recommend using `kOutOfRange` (the more specific
+ // error) when it applies so that callers who are iterating through
+ // a space can easily look for an `kOutOfRange` error to detect when
+ // they are done.
kOutOfRange = 11,
+
+ // The operation is not implemented or is not supported/enabled in this
+ // service.
kUnimplemented = 12,
+
+ // Internal errors. This means that some invariants expected by the
+ // underlying system have been broken. This error code is reserved
+ // for serious errors.
kInternal = 13,
+
+ // The service is currently unavailable. This is most likely a
+ // transient condition, which can be corrected by retrying with
+ // a backoff. Note that it is not always safe to retry
+ // non-idempotent operations.
+ //
+ // See litmus test above for deciding between `kFailedPrecondition`,
+ // `kAborted`, and `kUnavailable`.
kUnavailable = 14,
+
+ // Unrecoverable data loss or corruption.
kDataLoss = 15,
+
+ // The request does not have valid authentication credentials for the
+ // operation.
kUnauthenticated = 16,
+
+ // An extra enum entry to prevent people from writing code that
+ // fails to compile when a new code is added.
+ //
+ // Nobody should ever reference this enumeration entry. In particular,
+ // if you write C++ code that switches on this enumeration, add a default:
+ // case instead of a case that mentions this enumeration entry.
+ //
+ // Nobody should rely on the value (currently 20) listed here. It
+ // may change in the future.
kDoNotUseReservedForFutureExpansionUseDefaultInSwitchInstead_ = 20
};