pub enum HttpError {
Network(Error),
Serialization(String),
Deserialization(String),
Http {
status: u16,
message: String,
body: Option<String>,
},
Auth(String),
Timeout,
Config(String),
Other(String),
}Expand description
HTTP client errors that can occur during API requests
Variants§
Network(Error)
Network or connection error
Serialization(String)
Request serialization error
Deserialization(String)
Response deserialization error
Http
HTTP error response (4xx, 5xx)
Auth(String)
Authentication error
Timeout
Request timeout
Config(String)
Invalid configuration
Other(String)
Generic error
Implementations§
Source§impl HttpError
impl HttpError
Sourcepub fn from_status(
status: u16,
message: impl Into<String>,
body: Option<String>,
) -> Self
pub fn from_status( status: u16, message: impl Into<String>, body: Option<String>, ) -> Self
Create an HTTP error from a status code and message
Sourcepub fn serialization_error(error: impl Display) -> Self
pub fn serialization_error(error: impl Display) -> Self
Create a serialization error
Sourcepub fn deserialization_error(error: impl Display) -> Self
pub fn deserialization_error(error: impl Display) -> Self
Create a deserialization error
Sourcepub fn is_client_error(&self) -> bool
pub fn is_client_error(&self) -> bool
Check if this is a client error (4xx)
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
Check if this is a server error (5xx)
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Check if this error is retryable
Trait Implementations§
Source§impl Error for HttpError
impl Error for HttpError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for HttpError
impl !RefUnwindSafe for HttpError
impl Send for HttpError
impl Sync for HttpError
impl Unpin for HttpError
impl !UnwindSafe for HttpError
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> 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> ValidateIp for Twhere
T: ToString,
impl<T> ValidateIp for Twhere
T: ToString,
Source§fn validate_ipv4(&self) -> bool
fn validate_ipv4(&self) -> bool
Validates whether the given string is an IP V4
Source§fn validate_ipv6(&self) -> bool
fn validate_ipv6(&self) -> bool
Validates whether the given string is an IP V6
Source§fn validate_ip(&self) -> bool
fn validate_ip(&self) -> bool
Validates whether the given string is an IP