roo_transport
API Documentation for roo_transport
Loading...
Searching...
No Matches
status.h
Go to the documentation of this file.
1#pragma once
2
3#include "roo_logging.h"
4
5namespace roo_transport {
6
7// Modeled after Google's gRPC status codes.
9 // Success (not an error).
10 kOk = 0,
11
12 // The operation was cancelled, typically by the caller.
14
15 // Unknown error. For example, this error may be returned when
16 // a `Status` value received from another address space belongs to
17 // an error space that is not known in this address space. Also
18 // errors raised by APIs that do not return enough error information
19 // may be converted to this error.
21
22 // The client specified an invalid argument. Note that this differs
23 // from `kFailedPrecondition`. `kInvalidArgument` indicates arguments
24 // that are problematic regardless of the state of the system
25 // (e.g., a malformed file name).
27
28 // The deadline expired before the operation could complete. For operations
29 // that change the state of the system, this error may be returned
30 // even if the operation has completed successfully. For example, a
31 // successful response from a server could have been delayed long
32 // enough for the deadline to expire.
34
35 // Some requested entity (e.g., file or directory) was not found.
36 //
37 // Note to server developers: if a request is denied for an entire class
38 // of users, such as gradual feature rollout or undocumented allowlist,
39 // `kNotFound` may be used. If a request is denied for some users within
40 // a class of users, such as user-based access control, `kPermissionDenied`
41 // must be used.
43
44 // The entity that a client attempted to create (e.g., file or directory)
45 // already exists.
47
48 // The caller does not have permission to execute the specified
49 // operation. `kPermissionDenied` must not be used for rejections
50 // caused by exhausting some resource (use `kResourceExhausted`
51 // instead for those errors). `kPermissionDenied` must not be
52 // used if the caller can not be identified (use `kUnauthenticated`
53 // instead for those errors). This error code does not imply the
54 // request is valid or the requested entity exists or satisfies
55 // other pre-conditions.
57
58 // The request does not have valid authentication credentials for the
59 // operation.
61
62 // Some resource has been exhausted, perhaps a per-user quota, or
63 // perhaps the entire file system is out of space.
65
66 // The operation was rejected because the system is not in a state
67 // required for the operation's execution. For example, the directory
68 // to be deleted is non-empty, an rmdir operation is applied to
69 // a non-directory, etc.
70 //
71 // Service implementors can use the following guidelines to decide
72 // between `kFailedPrecondition`, `kAborted`, and `kUnavailable`:
73 // (a) Use `kUnavailable` if the client can retry just the failing call.
74 // (b) Use `kAborted` if the client should retry at a higher level. For
75 // example, when a client-specified test-and-set fails, indicating the
76 // client should restart a read-modify-write sequence.
77 // (c) Use `kFailedPrecondition` if the client should not retry until
78 // the system state has been explicitly fixed. For example, if an "rmdir"
79 // fails because the directory is non-empty, `kFailedPrecondition`
80 // should be returned since the client should not retry unless
81 // the files are deleted from the directory.
83
84 // The operation was aborted, typically due to a concurrency issue such as
85 // a sequencer check failure or transaction abort.
86 //
87 // See the guidelines above for deciding between `kFailedPrecondition`,
88 // `kAborted`, and `kUnavailable`.
90
91 // The operation was attempted past the valid range. E.g., seeking or
92 // reading past end-of-file.
93 //
94 // Unlike `kInvalidArgument`, this error indicates a problem that may
95 // be fixed if the system state changes. For example, a 32-bit file
96 // system will generate `kInvalidArgument` if asked to read at an
97 // offset that is not in the range [0,2^32-1], but it will generate
98 // `kOutOfRange` if asked to read from an offset past the current
99 // file size.
100 //
101 // There is a fair bit of overlap between `kFailedPrecondition` and
102 // `kOutOfRange`. We recommend using `kOutOfRange` (the more specific
103 // error) when it applies so that callers who are iterating through
104 // a space can easily look for an `kOutOfRange` error to detect when
105 // they are done.
107
108 // The operation is not implemented or is not supported/enabled in this
109 // service.
111
112 // Internal errors. This means that some invariants expected by the
113 // underlying system have been broken. This error code is reserved
114 // for serious errors.
116
117 // The service is currently unavailable. This is most likely a
118 // transient condition, which can be corrected by retrying with
119 // a backoff. Note that it is not always safe to retry
120 // non-idempotent operations.
121 //
122 // See the guidelines above for deciding between `kFailedPrecondition`,
123 // `kAborted`, and `kUnavailable`.
125
126 // Unrecoverable data loss or corruption.
127 kDataLoss = 15
129
130const char* RpcStatusAsString(RpcStatus status);
131
132inline roo_logging::Stream& operator<<(roo_logging::Stream& s,
133 RpcStatus status) {
134 s << RpcStatusAsString(status);
135 return s;
136}
137
138} // namespace roo_transport
@ kPermissionDenied
Definition status.h:56
@ kAlreadyExists
Definition status.h:46
@ kInvalidArgument
Definition status.h:26
@ kUnauthenticated
Definition status.h:60
@ kFailedPrecondition
Definition status.h:82
@ kDeadlineExceeded
Definition status.h:33
@ kResourceExhausted
Definition status.h:64
const char * RpcStatusAsString(RpcStatus status)
Definition status.cpp:5
roo_logging::Stream & operator<<(roo_logging::Stream &s, RpcStatus status)
Definition status.h:132