status_code_enum.h 5.9 KB

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