gRPC  0.6.0
 All Classes Namespaces Functions Variables Enumerations Properties Pages
status.h
1 /*
2  *
3  * Copyright 2015, Google Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following disclaimer
14  * in the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of Google Inc. nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 
34 #ifndef GRPC_STATUS_H
35 #define GRPC_STATUS_H
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 typedef enum {
42  /* Not an error; returned on success */
43  GRPC_STATUS_OK = 0,
44 
45  /* The operation was cancelled (typically by the caller). */
46  GRPC_STATUS_CANCELLED = 1,
47 
48  /* Unknown error. An example of where this error may be returned is
49  if a Status value received from another address space belongs to
50  an error-space that is not known in this address space. Also
51  errors raised by APIs that do not return enough error information
52  may be converted to this error. */
53  GRPC_STATUS_UNKNOWN = 2,
54 
55  /* Client specified an invalid argument. Note that this differs
56  from FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments
57  that are problematic regardless of the state of the system
58  (e.g., a malformed file name). */
59  GRPC_STATUS_INVALID_ARGUMENT = 3,
60 
61  /* Deadline expired before operation could complete. For operations
62  that change the state of the system, this error may be returned
63  even if the operation has completed successfully. For example, a
64  successful response from a server could have been delayed long
65  enough for the deadline to expire. */
66  GRPC_STATUS_DEADLINE_EXCEEDED = 4,
67 
68  /* Some requested entity (e.g., file or directory) was not found. */
69  GRPC_STATUS_NOT_FOUND = 5,
70 
71  /* Some entity that we attempted to create (e.g., file or directory)
72  already exists. */
73  GRPC_STATUS_ALREADY_EXISTS = 6,
74 
75  /* The caller does not have permission to execute the specified
76  operation. PERMISSION_DENIED must not be used for rejections
77  caused by exhausting some resource (use RESOURCE_EXHAUSTED
78  instead for those errors). PERMISSION_DENIED must not be
79  used if the caller can not be identified (use UNAUTHENTICATED
80  instead for those errors). */
81  GRPC_STATUS_PERMISSION_DENIED = 7,
82 
83  /* The request does not have valid authentication credentials for the
84  operation. */
85  GRPC_STATUS_UNAUTHENTICATED = 16,
86 
87  /* Some resource has been exhausted, perhaps a per-user quota, or
88  perhaps the entire file system is out of space. */
89  GRPC_STATUS_RESOURCE_EXHAUSTED = 8,
90 
91  /* Operation was rejected because the system is not in a state
92  required for the operation's execution. For example, directory
93  to be deleted may be non-empty, an rmdir operation is applied to
94  a non-directory, etc.
95 
96  A litmus test that may help a service implementor in deciding
97  between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE:
98  (a) Use UNAVAILABLE if the client can retry just the failing call.
99  (b) Use ABORTED if the client should retry at a higher-level
100  (e.g., restarting a read-modify-write sequence).
101  (c) Use FAILED_PRECONDITION if the client should not retry until
102  the system state has been explicitly fixed. E.g., if an "rmdir"
103  fails because the directory is non-empty, FAILED_PRECONDITION
104  should be returned since the client should not retry unless
105  they have first fixed up the directory by deleting files from it.
106  (d) Use FAILED_PRECONDITION if the client performs conditional
107  REST Get/Update/Delete on a resource and the resource on the
108  server does not match the condition. E.g., conflicting
109  read-modify-write on the same resource. */
110  GRPC_STATUS_FAILED_PRECONDITION = 9,
111 
112  /* The operation was aborted, typically due to a concurrency issue
113  like sequencer check failures, transaction aborts, etc.
114 
115  See litmus test above for deciding between FAILED_PRECONDITION,
116  ABORTED, and UNAVAILABLE. */
117  GRPC_STATUS_ABORTED = 10,
118 
119  /* Operation was attempted past the valid range. E.g., seeking or
120  reading past end of file.
121 
122  Unlike INVALID_ARGUMENT, this error indicates a problem that may
123  be fixed if the system state changes. For example, a 32-bit file
124  system will generate INVALID_ARGUMENT if asked to read at an
125  offset that is not in the range [0,2^32-1], but it will generate
126  OUT_OF_RANGE if asked to read from an offset past the current
127  file size.
128 
129  There is a fair bit of overlap between FAILED_PRECONDITION and
130  OUT_OF_RANGE. We recommend using OUT_OF_RANGE (the more specific
131  error) when it applies so that callers who are iterating through
132  a space can easily look for an OUT_OF_RANGE error to detect when
133  they are done. */
134  GRPC_STATUS_OUT_OF_RANGE = 11,
135 
136  /* Operation is not implemented or not supported/enabled in this service. */
137  GRPC_STATUS_UNIMPLEMENTED = 12,
138 
139  /* Internal errors. Means some invariants expected by underlying
140  system has been broken. If you see one of these errors,
141  something is very broken. */
142  GRPC_STATUS_INTERNAL = 13,
143 
144  /* The service is currently unavailable. This is a most likely a
145  transient condition and may be corrected by retrying with
146  a backoff.
147 
148  See litmus test above for deciding between FAILED_PRECONDITION,
149  ABORTED, and UNAVAILABLE. */
150  GRPC_STATUS_UNAVAILABLE = 14,
151 
152  /* Unrecoverable data loss or corruption. */
153  GRPC_STATUS_DATA_LOSS = 15,
154 
155  /* Force users to include a default branch: */
156  GRPC_STATUS__DO_NOT_USE = -1
157 } grpc_status_code;
158 
159 #ifdef __cplusplus
160 }
161 #endif
162 
163 #endif /* GRPC_STATUS_H */