#[non_exhaustive]pub enum Error {
Config(Box<ErrorContext>),
Authentication(Box<ErrorContext>),
PermissionDenied(Box<ErrorContext>),
NotFound(Box<ErrorContext>),
Conflict(Box<ErrorContext>),
RateLimited(Box<ErrorContext>),
Validation(Box<ErrorContext>),
Unavailable(Box<ErrorContext>),
Timeout(Box<ErrorContext>),
Unsupported(Box<ErrorContext>),
Cancelled(Box<ErrorContext>),
}Expand description
The SDK error. Match on the variant or use Error::code.
Messages never contain secrets, tokens, request bodies or unfiltered response bodies.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Config(Box<ErrorContext>)
CONFIG: invalid or missing configuration.
Authentication(Box<ErrorContext>)
AUTHENTICATION: HTTP 401.
PermissionDenied(Box<ErrorContext>)
PERMISSION_DENIED: HTTP 403.
NotFound(Box<ErrorContext>)
NOT_FOUND: HTTP 404 or a missing record.
Conflict(Box<ErrorContext>)
CONFLICT: HTTP 409, 412 or a CAS mismatch.
RateLimited(Box<ErrorContext>)
RATE_LIMITED: HTTP 429 (see Error::retry_after).
Validation(Box<ErrorContext>)
VALIDATION: rejected input.
UNAVAILABLE: network error or HTTP 500/502/503.
Timeout(Box<ErrorContext>)
TIMEOUT: a deadline was exceeded.
Unsupported(Box<ErrorContext>)
UNSUPPORTED: capability not offered by the service.
Cancelled(Box<ErrorContext>)
CANCELLED: the caller cancelled.
Implementations§
Source§impl Error
impl Error
Sourcepub fn new(code: ErrorCode, message: impl Into<String>) -> Self
pub fn new(code: ErrorCode, message: impl Into<String>) -> Self
Creates an error with the given code; retryable defaults per code.
Sourcepub fn from_status(status: u16, message: impl Into<String>) -> Self
pub fn from_status(status: u16, message: impl Into<String>) -> Self
Error for an HTTP status (SPEC §2.1 mapping); non-error statuses map to UNAVAILABLE.
Sourcepub fn validation(message: impl Into<String>) -> Self
pub fn validation(message: impl Into<String>) -> Self
VALIDATION error.
UNAVAILABLE error.
Sourcepub fn unsupported(message: impl Into<String>) -> Self
pub fn unsupported(message: impl Into<String>) -> Self
UNSUPPORTED error.
Sourcepub fn with_status(self, status: u16) -> Self
pub fn with_status(self, status: u16) -> Self
Sets the HTTP status.
Sourcepub fn with_request_id(self, request_id: impl Into<String>) -> Self
pub fn with_request_id(self, request_id: impl Into<String>) -> Self
Sets the vendor request id.
Sourcepub fn with_retryable(self, retryable: bool) -> Self
pub fn with_retryable(self, retryable: bool) -> Self
Overrides whether the error is retryable.
Sourcepub fn with_retry_after(self, retry_after: Duration) -> Self
pub fn with_retry_after(self, retry_after: Duration) -> Self
Sets the server-requested wait before a retry.
Sourcepub fn with_source(self, source: impl Error + Send + Sync + 'static) -> Self
pub fn with_source(self, source: impl Error + Send + Sync + 'static) -> Self
Sets the underlying cause (it must not expose secrets).
Sourcepub fn with_message(self, message: impl Into<String>) -> Self
pub fn with_message(self, message: impl Into<String>) -> Self
Replaces the message.
Sourcepub fn http_status(&self) -> Option<u16>
pub fn http_status(&self) -> Option<u16>
HTTP status when the error came from a response.
Sourcepub fn request_id(&self) -> Option<&str>
pub fn request_id(&self) -> Option<&str>
Vendor request id when the response carried one.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether retrying the same call may succeed.
Sourcepub fn retry_after(&self) -> Option<Duration>
pub fn retry_after(&self) -> Option<Duration>
Server-requested wait (Retry-After) when known.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()