#[non_exhaustive]pub enum ErrorCode {
Config,
Authentication,
PermissionDenied,
NotFound,
Conflict,
RateLimited,
Validation,
Unavailable,
Timeout,
Unsupported,
Cancelled,
}Expand description
Canonical error codes. The wire value (as_str) is the same in every language.
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.
Config
Invalid or missing configuration.
Authentication
Bad credentials (HTTP 401).
PermissionDenied
Credentials lack permission (HTTP 403).
NotFound
Missing resource (HTTP 404).
Conflict
Conflict or failed precondition (HTTP 409, 412, CAS mismatch).
RateLimited
Throttled (HTTP 429).
Validation
Rejected input (HTTP 400, 413, 422, other 4xx, client-side validation).
Network failure or server error (HTTP 500, 502, 503).
Timeout
A deadline was exceeded (HTTP 408, 504).
Unsupported
The service or deployment does not offer the capability (HTTP 501).
Cancelled
The caller cancelled the operation.
Implementations§
Source§impl ErrorCode
impl ErrorCode
Sourcepub fn default_retryable(self) -> bool
pub fn default_retryable(self) -> bool
Whether errors with this code are retryable by default.
Sourcepub fn reason(self) -> &'static str
pub fn reason(self) -> &'static str
Short human reason used in error messages, e.g. "not found".
Sourcepub fn from_http_status(status: u16) -> Option<ErrorCode>
pub fn from_http_status(status: u16) -> Option<ErrorCode>
Code for an HTTP status according to SPEC §2.1 (None for 1xx–3xx).
Trait Implementations§
impl Copy for ErrorCode
impl Eq for ErrorCode
Source§impl Ord for ErrorCode
impl Ord for ErrorCode
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for ErrorCode
impl PartialOrd for ErrorCode
impl StructuralPartialEq for ErrorCode
Auto Trait Implementations§
impl Forget for ErrorCode
impl Freeze for ErrorCode
impl Move for ErrorCode
impl RefUnwindSafe for ErrorCode
impl Send for ErrorCode
impl Sync for ErrorCode
impl Unpin for ErrorCode
impl UnsafeUnpin for ErrorCode
impl UnwindSafe for ErrorCode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more