pub enum Error {
Show 16 variants
Cancelled(ErrorStatus),
Unknown(ErrorStatus),
InvalidArgument(ErrorStatus),
DeadlineExceeded(ErrorStatus),
NotFound(ErrorStatus),
AlreadyExists(ErrorStatus),
PermissionDenied(ErrorStatus),
Unauthenticated(ErrorStatus),
ResourceExhausted(ErrorStatus),
FailedPrecondition(ErrorStatus),
Aborted(ErrorStatus),
OutOfRange(ErrorStatus),
Unimplemented(ErrorStatus),
Internal(ErrorStatus),
Unavailable(ErrorStatus),
DataLoss(ErrorStatus),
}
Variants§
Cancelled(ErrorStatus)
The operation was cancelled, typically by the caller.
Mapping | Code | Description |
---|---|---|
HTTP | 499 | Client Closed Request |
gRPC | 1 | Cancelled |
Unknown(ErrorStatus)
Unknown error. For example, this error may be returned when a ErrorStatus
value received from another address space belongs to an error space
that is not known in this address space. Also errors raised by APIs
that do not return enough error information may be converted to this
error.
Mapping | Code | Description |
---|---|---|
HTTP | 500 | Internal Server Error |
gRPC | 2 | Unknown |
InvalidArgument(ErrorStatus)
The client specified an invalid argument. Note that this differs
from Error::FailedPrecondition
. Error::InvalidArgument
indicates arguments
that are problematic regardless of the state of the system
(e.g., a malformed file name).
Mapping | Code | Description |
---|---|---|
HTTP | 400 | Bad Request |
gRPC | 3 | Invalid argument |
DeadlineExceeded(ErrorStatus)
The deadline expired before the operation could complete. For operations that change the state of the system, this error may be returned even if the operation has completed successfully. For example, a successful response from a server could have been delayed long enough for the deadline to expire.
Mapping | Code | Description |
---|---|---|
HTTP | 504 | Gateway Timeout |
gRPC | 4 | Deadline exceeded |
NotFound(ErrorStatus)
Some requested entity (e.g., file or directory) was not found.
Note to server developers: if a request is denied for an entire class
of users, such as gradual feature rollout or undocumented allowlist,
Error::NotFound
may be used. If a request is denied for some users
within a class of users, such as user-based access control,
Error::PermissionDenied
must be used.
Mapping | Code | Description |
---|---|---|
HTTP | 404 | Not Found |
gRPC | 5 | Not found |
AlreadyExists(ErrorStatus)
The entity that a client attempted to create (e.g., file or directory) already exists.
Mapping | Code | Description |
---|---|---|
HTTP | 409 | Conflict |
gRPC | 6 | Already exists |
PermissionDenied(ErrorStatus)
The caller does not have permission to execute the specified
operation. Error::PermissionDenied
must not be used for rejections
caused by exhausting some resource (use Error::ResourceExhausted
instead for those errors). Error::PermissionDenied
must not be
used if the caller can not be identified (use Error::Unauthenticated
instead for those errors). This error code does not imply the
request is valid or the requested entity exists or satisfies
other pre-conditions.
Mapping | Code | Description |
---|---|---|
HTTP | 403 | Forbidden |
gRPC | 7 | Permission denied |
Unauthenticated(ErrorStatus)
The request does not have valid authentication credentials for the operation.
Mapping | Code | Description |
---|---|---|
HTTP | 401 | Unauthorized |
gRPC | 16 | Permission denied |
ResourceExhausted(ErrorStatus)
Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space.
Mapping | Code | Description |
---|---|---|
HTTP | 429 | Too Many Requests |
gRPC | 8 | Permission denied |
FailedPrecondition(ErrorStatus)
The operation was rejected because the system is not in a state required for the operation’s execution. For example, the directory to be deleted is non-empty, an rmdir operation is applied to a non-directory, etc.
Service implementors can use the following guidelines to decide
between Error::FailedPrecondition
, Error::Aborted
, and
Error::Unavailable
:
- Use
Error::Unavailable
if the client can retry just the failing call. - Use
Error::Aborted
if the client should retry at a higher level. For example, when a client-specified test-and-set fails, indicating the client should restart a read-modify-write sequence. - Use
Error::FailedPrecondition
if the client should not retry until the system state has been explicitly fixed. For example, if an “rmdir” fails because the directory is non-empty,Error::FailedPrecondition
should be returned since the client should not retry unless the files are deleted from the directory.
Mapping | Code | Description |
---|---|---|
HTTP | 400 | Bad Request |
gRPC | 9 | Failed precondition |
Aborted(ErrorStatus)
The operation was aborted, typically due to a concurrency issue such as a sequencer check failure or transaction abort.
See the guidelines above for deciding between
Error::FailedPrecondition
, Error::Aborted
, and
Error::Unavailable
.
Mapping | Code | Description |
---|---|---|
HTTP | 409 | Conflict |
gRPC | 10 | Aborted |
OutOfRange(ErrorStatus)
The operation was attempted past the valid range. E.g., seeking or reading past end-of-file.
Unlike Error::InvalidArgument
, this error indicates a problem that
may be fixed if the system state changes. For example, a 32-bit file
system will generate Error::InvalidArgument
if asked to read at an
offset that is not in the range [0,2^32-1], but it will generate
Error::OutOfRange
if asked to read from an offset past the current
file size.
There is a fair bit of overlap between Error::FailedPrecondition
and
Error::OutOfRange
. We recommend using Error::OutOfRange
(the
more specific error) when it applies so that callers who are iterating
through a space can easily look for an Error::OutOfRange
error to
detect when they are done.
Mapping | Code | Description |
---|---|---|
HTTP | 400 | Bad Request |
gRPC | 11 | Out of range |
Unimplemented(ErrorStatus)
The operation is not implemented or is not supported/enabled in this service.
Mapping | Code | Description |
---|---|---|
HTTP | 501 | Not implemented |
gRPC | 12 | Unimplemented |
Internal(ErrorStatus)
Internal errors. This means that some invariants expected by the underlying system have been broken. This error code is reserved for serious errors.
Mapping | Code | Description |
---|---|---|
HTTP | 500 | Internal Server Error |
gRPC | 13 | Internal |
The service is currently unavailable. This is most likely a transient condition, which can be corrected by retrying with a backoff. Note that it is not always safe to retry non-idempotent operations.
See the guidelines above for deciding between
Error::FailedPrecondition
, Error::Aborted
, and
Error::Unavailable
.
Mapping | Code | Description |
---|---|---|
HTTP | 503 | Service Unavailable |
gRPC | 14 | Unavailable |
DataLoss(ErrorStatus)
Unrecoverable data loss or corruption.
Mapping | Code | Description |
---|---|---|
HTTP | 500 | Internal Server Error |
gRPC | 15 | Data loss |
Implementations§
Source§impl Error
impl Error
Sourcepub fn code(&self) -> i32
pub fn code(&self) -> i32
Returns the gRPC code value.
See https://github.com/googleapis/googleapis/blob/f36c65081b19e0758ef5696feca27c7dcee5475e/google/rpc/code.proto.
pub fn cancelled<S: AsRef<str>>(message: S) -> Error
pub fn unknown<S: AsRef<str>>(message: S) -> Error
pub fn invalid_argument<S: AsRef<str>>(message: S) -> Error
pub fn deadline_exceeded<S: AsRef<str>>(message: S) -> Error
pub fn not_found<S: AsRef<str>>(message: S) -> Error
pub fn already_exists<S: AsRef<str>>(message: S) -> Error
pub fn permission_denied<S: AsRef<str>>(message: S) -> Error
pub fn unauthenticated<S: AsRef<str>>(message: S) -> Error
pub fn resource_exhausted<S: AsRef<str>>(message: S) -> Error
pub fn failed_precondition<S: AsRef<str>>(message: S) -> Error
pub fn aborted<S: AsRef<str>>(message: S) -> Error
pub fn out_of_range<S: AsRef<str>>(message: S) -> Error
pub fn unimplemented<S: AsRef<str>>(message: S) -> Error
pub fn internal<S: AsRef<str>>(message: S) -> Error
pub fn data_loss<S: AsRef<str>>(message: S) -> Error
Sourcepub fn with_error<E: Display>(self, error: E) -> Error
pub fn with_error<E: Display>(self, error: E) -> Error
Appends a ErrorDetails::DebugInfo
with info from error
.