Enum Error

Source
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.

MappingCodeDescription
HTTP499Client Closed Request
gRPC1Cancelled
§

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.

MappingCodeDescription
HTTP500Internal Server Error
gRPC2Unknown
§

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).

MappingCodeDescription
HTTP400Bad Request
gRPC3Invalid 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.

MappingCodeDescription
HTTP504Gateway Timeout
gRPC4Deadline 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.

MappingCodeDescription
HTTP404Not Found
gRPC5Not found
§

AlreadyExists(ErrorStatus)

The entity that a client attempted to create (e.g., file or directory) already exists.

MappingCodeDescription
HTTP409Conflict
gRPC6Already 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.

MappingCodeDescription
HTTP403Forbidden
gRPC7Permission denied
§

Unauthenticated(ErrorStatus)

The request does not have valid authentication credentials for the operation.

MappingCodeDescription
HTTP401Unauthorized
gRPC16Permission denied
§

ResourceExhausted(ErrorStatus)

Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space.

MappingCodeDescription
HTTP429Too Many Requests
gRPC8Permission 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.
MappingCodeDescription
HTTP400Bad Request
gRPC9Failed 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.

MappingCodeDescription
HTTP409Conflict
gRPC10Aborted
§

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.

MappingCodeDescription
HTTP400Bad Request
gRPC11Out of range
§

Unimplemented(ErrorStatus)

The operation is not implemented or is not supported/enabled in this service.

MappingCodeDescription
HTTP501Not implemented
gRPC12Unimplemented
§

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.

MappingCodeDescription
HTTP500Internal Server Error
gRPC13Internal
§

Unavailable(ErrorStatus)

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.

MappingCodeDescription
HTTP503Service Unavailable
gRPC14Unavailable
§

DataLoss(ErrorStatus)

Unrecoverable data loss or corruption.

MappingCodeDescription
HTTP500Internal Server Error
gRPC15Data loss

Implementations§

Source§

impl Error

Source

pub fn inner(&self) -> &ErrorStatus

Source§

impl Error

Source

pub fn code(&self) -> i32

Returns the gRPC code value.

See https://github.com/googleapis/googleapis/blob/f36c65081b19e0758ef5696feca27c7dcee5475e/google/rpc/code.proto.

Source

pub fn cancelled<S: AsRef<str>>(message: S) -> Error

Source

pub fn unknown<S: AsRef<str>>(message: S) -> Error

Source

pub fn invalid_argument<S: AsRef<str>>(message: S) -> Error

Source

pub fn deadline_exceeded<S: AsRef<str>>(message: S) -> Error

Source

pub fn not_found<S: AsRef<str>>(message: S) -> Error

Source

pub fn already_exists<S: AsRef<str>>(message: S) -> Error

Source

pub fn permission_denied<S: AsRef<str>>(message: S) -> Error

Source

pub fn unauthenticated<S: AsRef<str>>(message: S) -> Error

Source

pub fn resource_exhausted<S: AsRef<str>>(message: S) -> Error

Source

pub fn failed_precondition<S: AsRef<str>>(message: S) -> Error

Source

pub fn aborted<S: AsRef<str>>(message: S) -> Error

Source

pub fn out_of_range<S: AsRef<str>>(message: S) -> Error

Source

pub fn unimplemented<S: AsRef<str>>(message: S) -> Error

Source

pub fn internal<S: AsRef<str>>(message: S) -> Error

Source

pub fn unavailable<S: AsRef<str>>(message: S) -> Error

Source

pub fn data_loss<S: AsRef<str>>(message: S) -> Error

Source

pub fn with_error<E: Display>(self, error: E) -> Error

Appends a ErrorDetails::DebugInfo with info from error.

Trait Implementations§

Source§

impl Clone for Error

Source§

fn clone(&self) -> Error

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl<'_derivative_strum> From<&'_derivative_strum Error> for &'static str

Source§

fn from(x: &'_derivative_strum Error) -> &'static str

Converts to this type from the input type.
Source§

impl From<Error> for &'static str

Source§

fn from(x: Error) -> &'static str

Converts to this type from the input type.
Source§

impl From<Error> for ErrorStatus

Source§

fn from(value: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnwindSafe for Error

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.