Jan Tattermusch | a7fff86 | 2015-02-13 11:08:08 -0800 | [diff] [blame] | 1 | #region Copyright notice and license |
| 2 | |
Jan Tattermusch | af77b3d | 2015-02-13 11:22:21 -0800 | [diff] [blame] | 3 | // Copyright 2015, Google Inc. |
Jan Tattermusch | a7fff86 | 2015-02-13 11:08:08 -0800 | [diff] [blame] | 4 | // All rights reserved. |
Craig Tiller | 190d360 | 2015-02-18 09:23:38 -0800 | [diff] [blame] | 5 | // |
Jan Tattermusch | a7fff86 | 2015-02-13 11:08:08 -0800 | [diff] [blame] | 6 | // Redistribution and use in source and binary forms, with or without |
| 7 | // modification, are permitted provided that the following conditions are |
| 8 | // met: |
Craig Tiller | 190d360 | 2015-02-18 09:23:38 -0800 | [diff] [blame] | 9 | // |
Jan Tattermusch | a7fff86 | 2015-02-13 11:08:08 -0800 | [diff] [blame] | 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. |
Craig Tiller | 190d360 | 2015-02-18 09:23:38 -0800 | [diff] [blame] | 19 | // |
Jan Tattermusch | a7fff86 | 2015-02-13 11:08:08 -0800 | [diff] [blame] | 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 | #endregion |
| 33 | |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 34 | using System; |
| 35 | |
Jan Tattermusch | 3086862 | 2015-02-19 09:22:33 -0800 | [diff] [blame^] | 36 | namespace Grpc.Core |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 37 | { |
| 38 | // TODO: element names should changed to comply with C# naming conventions. |
| 39 | /// <summary> |
Jan Tattermusch | 3086862 | 2015-02-19 09:22:33 -0800 | [diff] [blame^] | 40 | /// based on grpc_status_code from grpc/status.h |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 41 | /// </summary> |
| 42 | public enum StatusCode |
| 43 | { |
| 44 | /* Not an error; returned on success |
| 45 | |
| 46 | HTTP Mapping: 200 OK */ |
Jan Tattermusch | 3086862 | 2015-02-19 09:22:33 -0800 | [diff] [blame^] | 47 | OK = 0, |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 48 | /* The operation was cancelled (typically by the caller). |
| 49 | |
| 50 | HTTP Mapping: 499 Client Closed Request */ |
Jan Tattermusch | 3086862 | 2015-02-19 09:22:33 -0800 | [diff] [blame^] | 51 | Cancelled = 1, |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 52 | /* Unknown error. An example of where this error may be returned is |
| 53 | if a Status value received from another address space belongs to |
| 54 | an error-space that is not known in this address space. Also |
| 55 | errors raised by APIs that do not return enough error information |
| 56 | may be converted to this error. |
| 57 | |
| 58 | HTTP Mapping: 500 Internal Server Error */ |
Jan Tattermusch | 3086862 | 2015-02-19 09:22:33 -0800 | [diff] [blame^] | 59 | Unknown = 2, |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 60 | /* Client specified an invalid argument. Note that this differs |
| 61 | from FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments |
| 62 | that are problematic regardless of the state of the system |
| 63 | (e.g., a malformed file name). |
| 64 | |
| 65 | HTTP Mapping: 400 Bad Request */ |
Jan Tattermusch | 3086862 | 2015-02-19 09:22:33 -0800 | [diff] [blame^] | 66 | InvalidArgument = 3, |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 67 | /* Deadline expired before operation could complete. For operations |
| 68 | that change the state of the system, this error may be returned |
| 69 | even if the operation has completed successfully. For example, a |
| 70 | successful response from a server could have been delayed long |
| 71 | enough for the deadline to expire. |
| 72 | |
| 73 | HTTP Mapping: 504 Gateway Timeout */ |
Jan Tattermusch | 3086862 | 2015-02-19 09:22:33 -0800 | [diff] [blame^] | 74 | DeadlineExceeded = 4, |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 75 | /* Some requested entity (e.g., file or directory) was not found. |
| 76 | |
| 77 | HTTP Mapping: 404 Not Found */ |
Jan Tattermusch | 3086862 | 2015-02-19 09:22:33 -0800 | [diff] [blame^] | 78 | NotFound = 5, |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 79 | /* Some entity that we attempted to create (e.g., file or directory) |
| 80 | already exists. |
| 81 | |
| 82 | HTTP Mapping: 409 Conflict */ |
Jan Tattermusch | 3086862 | 2015-02-19 09:22:33 -0800 | [diff] [blame^] | 83 | AlreadyExists = 6, |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 84 | /* The caller does not have permission to execute the specified |
| 85 | operation. PERMISSION_DENIED must not be used for rejections |
| 86 | caused by exhausting some resource (use RESOURCE_EXHAUSTED |
| 87 | instead for those errors). PERMISSION_DENIED must not be |
| 88 | used if the caller can not be identified (use UNAUTHENTICATED |
| 89 | instead for those errors). |
| 90 | |
| 91 | HTTP Mapping: 403 Forbidden */ |
Jan Tattermusch | 3086862 | 2015-02-19 09:22:33 -0800 | [diff] [blame^] | 92 | PermissionDenied = 7, |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 93 | /* The request does not have valid authentication credentials for the |
| 94 | operation. |
| 95 | |
| 96 | HTTP Mapping: 401 Unauthorized */ |
Jan Tattermusch | 3086862 | 2015-02-19 09:22:33 -0800 | [diff] [blame^] | 97 | Unauthenticated = 16, |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 98 | /* Some resource has been exhausted, perhaps a per-user quota, or |
| 99 | perhaps the entire file system is out of space. |
| 100 | |
| 101 | HTTP Mapping: 429 Too Many Requests */ |
Jan Tattermusch | 3086862 | 2015-02-19 09:22:33 -0800 | [diff] [blame^] | 102 | ResourceExhausted = 8, |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 103 | /* Operation was rejected because the system is not in a state |
| 104 | required for the operation's execution. For example, directory |
| 105 | to be deleted may be non-empty, an rmdir operation is applied to |
| 106 | a non-directory, etc. |
| 107 | |
| 108 | A litmus test that may help a service implementor in deciding |
| 109 | between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE: |
| 110 | (a) Use UNAVAILABLE if the client can retry just the failing call. |
| 111 | (b) Use ABORTED if the client should retry at a higher-level |
| 112 | (e.g., restarting a read-modify-write sequence). |
| 113 | (c) Use FAILED_PRECONDITION if the client should not retry until |
| 114 | the system state has been explicitly fixed. E.g., if an "rmdir" |
| 115 | fails because the directory is non-empty, FAILED_PRECONDITION |
| 116 | should be returned since the client should not retry unless |
| 117 | they have first fixed up the directory by deleting files from it. |
| 118 | (d) Use FAILED_PRECONDITION if the client performs conditional |
| 119 | REST Get/Update/Delete on a resource and the resource on the |
| 120 | server does not match the condition. E.g., conflicting |
| 121 | read-modify-write on the same resource. |
| 122 | |
| 123 | HTTP Mapping: 400 Bad Request |
| 124 | |
| 125 | NOTE: HTTP spec says 412 Precondition Failed should only be used if |
| 126 | the request contains Etag related headers. So if the server does see |
| 127 | Etag related headers in the request, it may choose to return 412 |
| 128 | instead of 400 for this error code. */ |
Jan Tattermusch | 3086862 | 2015-02-19 09:22:33 -0800 | [diff] [blame^] | 129 | FailedPrecondition = 9, |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 130 | /* The operation was aborted, typically due to a concurrency issue |
| 131 | like sequencer check failures, transaction aborts, etc. |
| 132 | |
| 133 | See litmus test above for deciding between FAILED_PRECONDITION, |
| 134 | ABORTED, and UNAVAILABLE. |
| 135 | |
| 136 | HTTP Mapping: 409 Conflict */ |
Jan Tattermusch | 3086862 | 2015-02-19 09:22:33 -0800 | [diff] [blame^] | 137 | Aborted = 10, |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 138 | /* Operation was attempted past the valid range. E.g., seeking or |
| 139 | reading past end of file. |
| 140 | |
| 141 | Unlike INVALID_ARGUMENT, this error indicates a problem that may |
| 142 | be fixed if the system state changes. For example, a 32-bit file |
| 143 | system will generate INVALID_ARGUMENT if asked to read at an |
| 144 | offset that is not in the range [0,2^32-1], but it will generate |
| 145 | OUT_OF_RANGE if asked to read from an offset past the current |
| 146 | file size. |
| 147 | |
| 148 | There is a fair bit of overlap between FAILED_PRECONDITION and |
| 149 | OUT_OF_RANGE. We recommend using OUT_OF_RANGE (the more specific |
| 150 | error) when it applies so that callers who are iterating through |
| 151 | a space can easily look for an OUT_OF_RANGE error to detect when |
| 152 | they are done. |
| 153 | |
| 154 | HTTP Mapping: 400 Bad Request */ |
Jan Tattermusch | 3086862 | 2015-02-19 09:22:33 -0800 | [diff] [blame^] | 155 | OutOfRange = 11, |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 156 | /* Operation is not implemented or not supported/enabled in this service. |
| 157 | |
| 158 | HTTP Mapping: 501 Not Implemented */ |
Jan Tattermusch | 3086862 | 2015-02-19 09:22:33 -0800 | [diff] [blame^] | 159 | Unimplemented = 12, |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 160 | /* Internal errors. Means some invariants expected by underlying |
| 161 | system has been broken. If you see one of these errors, |
| 162 | something is very broken. |
| 163 | |
| 164 | HTTP Mapping: 500 Internal Server Error */ |
Jan Tattermusch | 3086862 | 2015-02-19 09:22:33 -0800 | [diff] [blame^] | 165 | Internal = 13, |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 166 | /* The service is currently unavailable. This is a most likely a |
| 167 | transient condition and may be corrected by retrying with |
| 168 | a backoff. |
| 169 | |
| 170 | See litmus test above for deciding between FAILED_PRECONDITION, |
| 171 | ABORTED, and UNAVAILABLE. |
| 172 | |
| 173 | HTTP Mapping: 503 Service Unavailable */ |
Jan Tattermusch | 3086862 | 2015-02-19 09:22:33 -0800 | [diff] [blame^] | 174 | Unavailable = 14, |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 175 | /* Unrecoverable data loss or corruption. |
| 176 | |
| 177 | HTTP Mapping: 500 Internal Server Error */ |
Jan Tattermusch | 3086862 | 2015-02-19 09:22:33 -0800 | [diff] [blame^] | 178 | DataLoss = 15 |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 179 | } |
| 180 | } |
| 181 | |