pub enum Error {
Authentication {
code: u16,
message: String,
error_type: String,
details: String,
is_transient: bool,
http_status_code: u16,
error_subcode: u16,
},
RateLimit {
code: u16,
message: String,
error_type: String,
details: String,
retry_after: Duration,
is_transient: bool,
http_status_code: u16,
error_subcode: u16,
},
Validation {
code: u16,
message: String,
error_type: String,
details: String,
field: String,
is_transient: bool,
http_status_code: u16,
error_subcode: u16,
},
Network {
code: u16,
message: String,
error_type: String,
details: String,
temporary: bool,
is_transient: bool,
http_status_code: u16,
error_subcode: u16,
cause: Option<Error>,
},
Api {
code: u16,
message: String,
error_type: String,
details: String,
request_id: String,
is_transient: bool,
http_status_code: u16,
error_subcode: u16,
},
Http(Error),
Json(Error),
}Expand description
All error variants returned by the Threads API client.
Variants§
Authentication
An authentication or authorization failure (e.g. invalid/expired token).
Fields
RateLimit
The request was throttled by the API rate limiter.
Fields
Validation
A request parameter or payload failed validation.
Fields
Network
A transport-level failure (DNS, TCP, TLS, timeout, etc.).
Fields
Api
A generic API error that does not fit a more specific variant.
Fields
Http(Error)
An HTTP-level error from the underlying reqwest client.
Json(Error)
A JSON serialization or deserialization error.
Implementations§
Source§impl Error
impl Error
Sourcepub fn is_authentication(&self) -> bool
pub fn is_authentication(&self) -> bool
Returns true if this is an authentication error.
Sourcepub fn is_rate_limit(&self) -> bool
pub fn is_rate_limit(&self) -> bool
Returns true if this is a rate-limit error.
Sourcepub fn is_validation(&self) -> bool
pub fn is_validation(&self) -> bool
Returns true if this is a validation error.
Sourcepub fn is_network(&self) -> bool
pub fn is_network(&self) -> bool
Returns true if this is a network error.
Sourcepub fn is_transient(&self) -> bool
pub fn is_transient(&self) -> bool
Returns true if the API flagged this error as transient.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Returns true if the request can be retried (rate-limit, transient, or temporary network).
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 Freeze for Error
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl !UnwindSafe 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
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.