1/*
2 *
3 * Copyright 2015 gRPC authors.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18
19#ifndef GRPC_IMPL_CODEGEN_STATUS_H
20#define GRPC_IMPL_CODEGEN_STATUS_H
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26typedef enum {
27 /** Not an error; returned on success */
28 GRPC_STATUS_OK = 0,
29
30 /** The operation was cancelled (typically by the caller). */
31 GRPC_STATUS_CANCELLED = 1,
32
33 /** Unknown error. An example of where this error may be returned is
34 if a Status value received from another address space belongs to
35 an error-space that is not known in this address space. Also
36 errors raised by APIs that do not return enough error information
37 may be converted to this error. */
38 GRPC_STATUS_UNKNOWN = 2,
39
40 /** Client specified an invalid argument. Note that this differs
41 from FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments
42 that are problematic regardless of the state of the system
43 (e.g., a malformed file name). */
44 GRPC_STATUS_INVALID_ARGUMENT = 3,
45
46 /** Deadline expired before operation could complete. For operations
47 that change the state of the system, this error may be returned
48 even if the operation has completed successfully. For example, a
49 successful response from a server could have been delayed long
50 enough for the deadline to expire. */
51 GRPC_STATUS_DEADLINE_EXCEEDED = 4,
52
53 /** Some requested entity (e.g., file or directory) was not found. */
54 GRPC_STATUS_NOT_FOUND = 5,
55
56 /** Some entity that we attempted to create (e.g., file or directory)
57 already exists. */
58 GRPC_STATUS_ALREADY_EXISTS = 6,
59
60 /** The caller does not have permission to execute the specified
61 operation. PERMISSION_DENIED must not be used for rejections
62 caused by exhausting some resource (use RESOURCE_EXHAUSTED
63 instead for those errors). PERMISSION_DENIED must not be
64 used if the caller can not be identified (use UNAUTHENTICATED
65 instead for those errors). */
66 GRPC_STATUS_PERMISSION_DENIED = 7,
67
68 /** The request does not have valid authentication credentials for the
69 operation. */
70 GRPC_STATUS_UNAUTHENTICATED = 16,
71
72 /** Some resource has been exhausted, perhaps a per-user quota, or
73 perhaps the entire file system is out of space. */
74 GRPC_STATUS_RESOURCE_EXHAUSTED = 8,
75
76 /** Operation was rejected because the system is not in a state
77 required for the operation's execution. For example, directory
78 to be deleted may be non-empty, an rmdir operation is applied to
79 a non-directory, etc.
80
81 A litmus test that may help a service implementor in deciding
82 between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE:
83 (a) Use UNAVAILABLE if the client can retry just the failing call.
84 (b) Use ABORTED if the client should retry at a higher-level
85 (e.g., restarting a read-modify-write sequence).
86 (c) Use FAILED_PRECONDITION if the client should not retry until
87 the system state has been explicitly fixed. E.g., if an "rmdir"
88 fails because the directory is non-empty, FAILED_PRECONDITION
89 should be returned since the client should not retry unless
90 they have first fixed up the directory by deleting files from it.
91 (d) Use FAILED_PRECONDITION if the client performs conditional
92 REST Get/Update/Delete on a resource and the resource on the
93 server does not match the condition. E.g., conflicting
94 read-modify-write on the same resource. */
95 GRPC_STATUS_FAILED_PRECONDITION = 9,
96
97 /** The operation was aborted, typically due to a concurrency issue
98 like sequencer check failures, transaction aborts, etc.
99
100 See litmus test above for deciding between FAILED_PRECONDITION,
101 ABORTED, and UNAVAILABLE. */
102 GRPC_STATUS_ABORTED = 10,
103
104 /** Operation was attempted past the valid range. E.g., seeking or
105 reading past end of file.
106
107 Unlike INVALID_ARGUMENT, this error indicates a problem that may
108 be fixed if the system state changes. For example, a 32-bit file
109 system will generate INVALID_ARGUMENT if asked to read at an
110 offset that is not in the range [0,2^32-1], but it will generate
111 OUT_OF_RANGE if asked to read from an offset past the current
112 file size.
113
114 There is a fair bit of overlap between FAILED_PRECONDITION and
115 OUT_OF_RANGE. We recommend using OUT_OF_RANGE (the more specific
116 error) when it applies so that callers who are iterating through
117 a space can easily look for an OUT_OF_RANGE error to detect when
118 they are done. */
119 GRPC_STATUS_OUT_OF_RANGE = 11,
120
121 /** Operation is not implemented or not supported/enabled in this service. */
122 GRPC_STATUS_UNIMPLEMENTED = 12,
123
124 /** Internal errors. Means some invariants expected by underlying
125 system has been broken. If you see one of these errors,
126 something is very broken. */
127 GRPC_STATUS_INTERNAL = 13,
128
129 /** The service is currently unavailable. This is a most likely a
130 transient condition and may be corrected by retrying with
131 a backoff. Note that it is not always safe to retry non-idempotent
132 operations.
133
134 WARNING: Although data MIGHT not have been transmitted when this
135 status occurs, there is NOT A GUARANTEE that the server has not seen
136 anything. So in general it is unsafe to retry on this status code
137 if the call is non-idempotent.
138
139 See litmus test above for deciding between FAILED_PRECONDITION,
140 ABORTED, and UNAVAILABLE. */
141 GRPC_STATUS_UNAVAILABLE = 14,
142
143 /** Unrecoverable data loss or corruption. */
144 GRPC_STATUS_DATA_LOSS = 15,
145
146 /** Force users to include a default branch: */
147 GRPC_STATUS__DO_NOT_USE = -1
148} grpc_status_code;
149
150#ifdef __cplusplus
151}
152#endif
153
154#endif /* GRPC_IMPL_CODEGEN_STATUS_H */
155

source code of include/grpc/impl/codegen/status.h