#[non_exhaustive]pub struct ApiError {
pub status: u16,
pub error_code: ErrorCode,
pub message: String,
pub retry_after: Option<u64>,
}Expand description
Structured information from a non-2xx Snippe response.
The Snippe response envelope on error looks like:
{
"status": "error",
"code": 400,
"error_code": "validation_error",
"message": "amount is required"
}Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.status: u16HTTP status code.
error_code: ErrorCodeStable machine-readable Snippe error code (e.g. validation_error).
message: StringHuman-readable error message.
retry_after: Option<u64>Value of the X-Ratelimit-Reset header in seconds, if the response was
a 429 rate limit.
Implementations§
Source§impl ApiError
impl ApiError
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
True if this error is worth retrying with backoff.
5xxand thePAY_001code are retryable (transient processor / server issues).429 rate_limit_exceededis retryable, but you should wait untilSelf::retry_afterseconds before the next attempt.- All
4xxvalidation, auth, and conflict errors are not retryable.
Convenience: true if this is a 401 unauthorized.
Sourcepub fn is_idempotency_conflict(&self) -> bool
pub fn is_idempotency_conflict(&self) -> bool
Convenience: true if this is a 422 idempotency-conflict error.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ApiError
impl RefUnwindSafe for ApiError
impl Send for ApiError
impl Sync for ApiError
impl Unpin for ApiError
impl UnsafeUnpin for ApiError
impl UnwindSafe for ApiError
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.