2
0

StatusCode.swift 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * Copyright 2016, gRPC Authors All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. import Foundation
  17. /// Status codes for gRPC operations (replicated from status_code_enum.h)
  18. public enum StatusCode: Int {
  19. /// Not an error; returned on success.
  20. case ok = 0
  21. /// The operation was cancelled (typically by the caller).
  22. case cancelled = 1
  23. /// Unknown error. An example of where this error may be returned is if a
  24. /// Status value received from another address space belongs to an error-space
  25. /// that is not known in this address space. Also errors raised by APIs that
  26. /// do not return enough error information may be converted to this error.
  27. case unknown = 2
  28. /// Client specified an invalid argument. Note that this differs from
  29. /// FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments that are
  30. /// problematic regardless of the state of the system (e.g., a malformed file
  31. /// name).
  32. case invalidArgument = 3
  33. /// Deadline expired before operation could complete. For operations that
  34. /// change the state of the system, this error may be returned even if the
  35. /// operation has completed successfully. For example, a successful response
  36. /// from a server could have been delayed long enough for the deadline to
  37. /// expire.
  38. case deadlineExceeded = 4
  39. /// Some requested entity (e.g., file or directory) was not found.
  40. case notFound = 5
  41. /// Some entity that we attempted to create (e.g., file or directory) already
  42. /// exists.
  43. case alreadyExists = 6
  44. /// The caller does not have permission to execute the specified operation.
  45. /// PERMISSION_DENIED must not be used for rejections caused by exhausting
  46. /// some resource (use RESOURCE_EXHAUSTED instead for those errors).
  47. /// PERMISSION_DENIED must not be used if the caller can not be identified
  48. /// (use UNAUTHENTICATED instead for those errors).
  49. case permissionDenied = 7
  50. /// The request does not have valid authentication credentials for the
  51. /// operation.
  52. case unauthenticated = 16
  53. /// Some resource has been exhausted, perhaps a per-user quota, or perhaps the
  54. /// entire file system is out of space.
  55. case resourceExhausted = 8
  56. /// Operation was rejected because the system is not in a state required for
  57. /// the operation's execution. For example, directory to be deleted may be
  58. /// non-empty, an rmdir operation is applied to a non-directory, etc.
  59. ///
  60. /// A litmus test that may help a service implementor in deciding
  61. /// between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE:
  62. /// (a) Use UNAVAILABLE if the client can retry just the failing call.
  63. /// (b) Use ABORTED if the client should retry at a higher-level
  64. /// (e.g., restarting a read-modify-write sequence).
  65. /// (c) Use FAILED_PRECONDITION if the client should not retry until
  66. /// the system state has been explicitly fixed. E.g., if an "rmdir"
  67. /// fails because the directory is non-empty, FAILED_PRECONDITION
  68. /// should be returned since the client should not retry unless
  69. /// they have first fixed up the directory by deleting files from it.
  70. /// (d) Use FAILED_PRECONDITION if the client performs conditional
  71. /// REST Get/Update/Delete on a resource and the resource on the
  72. /// server does not match the condition. E.g., conflicting
  73. /// read-modify-write on the same resource.
  74. case failedPrecondition = 9
  75. /// The operation was aborted, typically due to a concurrency issue like
  76. /// sequencer check failures, transaction aborts, etc.
  77. ///
  78. /// See litmus test above for deciding between FAILED_PRECONDITION, ABORTED,
  79. /// and UNAVAILABLE.
  80. case aborted = 10
  81. /// Operation was attempted past the valid range. E.g., seeking or reading
  82. /// past end of file.
  83. ///
  84. /// Unlike INVALID_ARGUMENT, this error indicates a problem that may be fixed
  85. /// if the system state changes. For example, a 32-bit file system will
  86. /// generate INVALID_ARGUMENT if asked to read at an offset that is not in the
  87. /// range [0,2^32-1], but it will generate OUT_OF_RANGE if asked to read from
  88. /// an offset past the current file size.
  89. ///
  90. /// There is a fair bit of overlap between FAILED_PRECONDITION and
  91. /// OUT_OF_RANGE. We recommend using OUT_OF_RANGE (the more specific error)
  92. /// when it applies so that callers who are iterating through a space can
  93. /// easily look for an OUT_OF_RANGE error to detect when they are done.
  94. case outOfRange = 11
  95. /// Operation is not implemented or not supported/enabled in this service.
  96. case unimplemented = 12
  97. /// Internal errors. Means some invariants expected by underlying System has
  98. /// been broken. If you see one of these errors, Something is very broken.
  99. case internalError = 13
  100. /// The service is currently unavailable. This is a most likely a transient
  101. /// condition and may be corrected by retrying with a backoff.
  102. ///
  103. /// See litmus test above for deciding between FAILED_PRECONDITION, ABORTED,
  104. /// and UNAVAILABLE.
  105. case unavailable = 14
  106. /// Unrecoverable data loss or corruption.
  107. case dataLoss = 15
  108. /// Force users to include a default branch:
  109. case doNotUse = -1
  110. }