status.h 6.2 KB

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