#[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()
Auto Trait Implementations§
impl !RefUnwindSafe for Error
impl !UnwindSafe for Error
impl Forget for Error
impl Freeze for Error
impl Move for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request