Skip to main content

ErrorCode

Enum ErrorCode 

Source
#[non_exhaustive]
#[repr(i32)]
pub enum ErrorCode {
Show 16 variants Cancelled = 1, Unknown = 2, InvalidArgument = 3, DeadlineExceeded = 4, NotFound = 5, AlreadyExists = 6, PermissionDenied = 7, ResourceExhausted = 8, FailedPrecondition = 9, Aborted = 10, OutOfRange = 11, Unimplemented = 12, Internal = 13, Unavailable = 14, DataLoss = 15, Unauthenticated = 16,
}
Expand description

Derived from https://github.com/abseil/abseil-cpp/blob/master/absl/status/status.h. See the link for more information.

(Copyright 2019 The Abseil Authors.)

Unlike absl::StatusCode, this enum only allows representing non-OK values.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Cancelled = 1

Cancelled (gRPC code “CANCELLED”) indicates the operation was cancelled, typically by the caller.

§

Unknown = 2

Unknown (gRPC code “UNKNOWN”) indicates an unknown error occurred. In general, more specific errors should be raised, if possible. Errors raised by APIs that do not return enough error information may be converted to this error.

§

InvalidArgument = 3

InvalidArgument (gRPC code “INVALID_ARGUMENT”) indicates the caller specified an invalid argument, such as a malformed filename. Note that use of such errors should be narrowly limited to indicate the invalid nature of the arguments themselves. Errors with validly formed arguments that may cause errors with the state of the receiving system should be denoted with FailedPrecondition instead.

§

DeadlineExceeded = 4

DeadlineExceeded (gRPC code “DEADLINE_EXCEEDED”) indicates a deadline expired before the operation could complete. For operations that may change state within a 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.

§

NotFound = 5

NotFound (gRPC code “NOT_FOUND”) indicates some requested entity (such as a file or directory) was not found.

NotFound is useful if a request should be denied for an entire class of users, such as during a gradual feature rollout or undocumented allow list. If a request should be denied for specific sets of users, such as through user-based access control, use PermissionDenied instead.

§

AlreadyExists = 6

AlreadyExists (gRPC code “ALREADY_EXISTS”) indicates that the entity a caller attempted to create (such as a file or directory) is already present.

§

PermissionDenied = 7

PermissionDenied (gRPC code “PERMISSION_DENIED”) indicates that the caller does not have permission to execute the specified operation. Note that this error is different than an error due to an unauthenticated user. This error code does not imply the request is valid or the requested entity exists or satisfies any other pre-conditions.

PermissionDenied must not be used for rejections caused by exhausting some resource. Instead, use ResourceExhausted for those errors. PermissionDenied must not be used if the caller cannot be identified. Instead, use Unauthenticated for those errors.

§

ResourceExhausted = 8

ResourceExhausted (gRPC code “RESOURCE_EXHAUSTED”) indicates some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space.

§

FailedPrecondition = 9

FailedPrecondition (gRPC code “FAILED_PRECONDITION”) indicates that the operation was rejected because the system is not in a state required for the operation’s execution. For example, a directory to be deleted may be non-empty, an “rmdir” operation is applied to a non-directory, etc.

Some guidelines that may help a service implementer in deciding between FailedPrecondition, Aborted, and Unavailable:

  1. Use Unavailable if the client can retry just the failing call.
  2. Use Aborted if the client should retry at a higher transaction level (such as when a client-specified test-and-set fails, indicating the client should restart a read-modify-write sequence).
  3. Use FailedPrecondition if the client should not retry until the system state has been explicitly fixed. For example, if a “rmdir” fails because the directory is non-empty, FailedPrecondition should be returned since the client should not retry unless the files are deleted from the directory.
§

Aborted = 10

Aborted (gRPC code “ABORTED”) indicates the operation was aborted, typically due to a concurrency issue such as a sequencer check failure or a failed transaction.

See the guidelines above for deciding between FailedPrecondition, Aborted, and Unavailable.

§

OutOfRange = 11

OutOfRange (gRPC code “OUT_OF_RANGE”) indicates the operation was attempted past the valid range, such as seeking or reading past an end-of-file.

Unlike InvalidArgument, this error indicates a problem that may be fixed if the system state changes. For example, a 32-bit file system will generate InvalidArgument if asked to read at an offset that is not in the range [0,2^32-1], but it will generate OutOfRange if asked to read from an offset past the current file size.

There is a fair bit of overlap between FailedPrecondition and OutOfRange. We recommend using OutOfRange (the more specific error) when it applies so that callers who are iterating through a space can easily look for an OutOfRange error to detect when they are done.

§

Unimplemented = 12

Unimplemented (gRPC code “UNIMPLEMENTED”) indicates the operation is not implemented or supported in this service. In this case, the operation should not be re-attempted.

§

Internal = 13

Internal (gRPC code “INTERNAL”) indicates an internal error has occurred and some invariants expected by the underlying system have not been satisfied. This error code is reserved for serious errors.

§

Unavailable = 14

Unavailable (gRPC code “UNAVAILABLE”) indicates the service is currently unavailable and that this is most likely a transient condition. An error such as this can be corrected by retrying with a backoff scheme. Note that it is not always safe to retry non-idempotent operations.

See the guidelines above for deciding between FailedPrecondition, Aborted, and Unavailable.

§

DataLoss = 15

DataLoss (gRPC code “DATA_LOSS”) indicates that unrecoverable data loss or corruption has occurred. As this error is serious, proper alerting should be attached to errors such as this.

§

Unauthenticated = 16

Unauthenticated (gRPC code “UNAUTHENTICATED”) indicates that the request does not have valid authentication credentials for the operation. Correct the authentication and try again.

Implementations§

Source§

impl ErrorCode

Source

pub const fn from_repr(discriminant: i32) -> Option<ErrorCode>

Try to create Self from the raw representation

Source§

impl ErrorCode

Source

pub fn from_errno(errno: i32) -> Option<ErrorCode>

Source

pub fn from_error_kind(kind: ErrorKind) -> ErrorCode

Source

pub fn from_raw_os_error(err: &Error) -> Option<ErrorCode>

If err contains a raw_os_error(), returns it converted into an ErrorCode. Otherwise returns None.

Trait Implementations§

Source§

impl Clone for ErrorCode

Source§

fn clone(&self) -> ErrorCode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for ErrorCode

Source§

impl Debug for ErrorCode

Source§

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

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

impl Display for ErrorCode

If the alternate flag is set, prints the error code as a number, otherwise as text.

Source§

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

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

impl Eq for ErrorCode

Source§

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

Source§

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

Converts to this type from the input type.
Source§

impl From<ErrorCode> for &'static str

Source§

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

Converts to this type from the input type.
Source§

impl From<ErrorCode> for NonZeroI32

Source§

fn from(code: ErrorCode) -> Self

Converts to this type from the input type.
Source§

impl From<ErrorCode> for ThinStatus

Source§

fn from(code: ErrorCode) -> Self

Converts to this type from the input type.
Source§

impl FromStr for ErrorCode

Source§

type Err = ParseError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<ErrorCode, <Self as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for ErrorCode

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl IntoEnumIterator for ErrorCode

Source§

impl Ord for ErrorCode

Source§

fn cmp(&self, other: &ErrorCode) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for ErrorCode

Source§

fn eq(&self, other: &ErrorCode) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for ErrorCode

Source§

fn partial_cmp(&self, other: &ErrorCode) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for ErrorCode

Source§

impl TryFrom<&str> for ErrorCode

Source§

type Error = ParseError

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

fn try_from(s: &str) -> Result<ErrorCode, <Self as TryFrom<&str>>::Error>

Performs the conversion.
Source§

impl TryFrom<i32> for ErrorCode

If a value matches one of the defined error codes, returns it as an ErrorCode, otherwise returns a () error.

For converting from strings, use the std::str::FromStr instance.

Source§

type Error = ()

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

fn try_from(code: i32) -> Result<Self, ()>

Performs the conversion.
Source§

impl VariantArray for ErrorCode

Source§

const VARIANTS: &'static [Self]

Auto Trait Implementations§

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<M> ThinStatusExt for M
where M: Display,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.