pub enum Error {
Show 17 variants
Http {
status: StatusCode,
message: String,
response: Box<HttpErrorResponse>,
},
Transport(Box<dyn StdError + Send + Sync>),
Tls(Box<dyn StdError + Send + Sync>),
Timeout,
TooManyRedirects {
max: u32,
},
InvalidRedirectLocation,
InvalidUri(String),
InvalidRequest(String),
BodyParse(BodyError),
ResponseBodyTooLarge {
limit: usize,
},
Cookie(CookieErrorKind),
OAuth2(OAuth2ErrorKind),
Download(DownloadErrorKind),
WebSocket(WebSocketErrorKind),
Proxy(ProxyErrorKind),
Io(Error),
Other(Box<dyn StdError + Send + Sync>),
}Expand description
Unified error type for all zenwave operations.
Variants§
Http
HTTP server returned an error response (4xx/5xx status code).
This represents a successful HTTP connection where the server returned
an error status. The response body may contain additional error details
that can be deserialized using Error::deserialize_http_error.
Fields
status: StatusCodeHTTP status code
response: Box<HttpErrorResponse>Full HTTP error response details
Transport(Box<dyn StdError + Send + Sync>)
Network transport layer error (connection failed, DNS resolution failed, etc.).
Tls(Box<dyn StdError + Send + Sync>)
TLS/SSL error.
Timeout
Request timed out.
TooManyRedirects
Too many redirects were followed.
InvalidRedirectLocation
Invalid redirect Location header.
InvalidUri(String)
URI parsing error.
InvalidRequest(String)
Request construction error (invalid headers, body, etc.).
BodyParse(BodyError)
Response body parsing error (JSON, form, string, etc.).
ResponseBodyTooLarge
Response body exceeded the caller-provided in-memory limit.
Cookie(CookieErrorKind)
Cookie management error.
OAuth2(OAuth2ErrorKind)
OAuth2 authentication error.
Download(DownloadErrorKind)
File download error.
WebSocket(WebSocketErrorKind)
WebSocket error.
Proxy(ProxyErrorKind)
The proxy between the client and the target refused or broke the connection.
Io(Error)
I/O error (file operations, etc.).
Other(Box<dyn StdError + Send + Sync>)
Other uncategorized error.
Implementations§
Source§impl Error
impl Error
Sourcepub const fn is_network_error(&self) -> bool
pub const fn is_network_error(&self) -> bool
Check if this is a network transport error.
Sourcepub const fn is_timeout(&self) -> bool
pub const fn is_timeout(&self) -> bool
Check if this is a timeout error.
Sourcepub fn is_client_error(&self) -> bool
pub fn is_client_error(&self) -> bool
Check if this is a client error (4xx HTTP status).
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
Check if this is a server error (5xx HTTP status).
Sourcepub const fn is_redirect_error(&self) -> bool
pub const fn is_redirect_error(&self) -> bool
Check if this is a redirect-related error.
Sourcepub const fn is_request_error(&self) -> bool
pub const fn is_request_error(&self) -> bool
Check if this is a request construction error.
Sourcepub fn response_body(&self) -> Option<&str>
pub fn response_body(&self) -> Option<&str>
Get the response body text (if this is an HTTP error).
Sourcepub const fn response(&self) -> Option<&Response>
pub const fn response(&self) -> Option<&Response>
Get the full HTTP response (if this is an HTTP error).
Sourcepub fn deserialize_http_error<T: DeserializeOwned>(&self) -> Option<T>
pub fn deserialize_http_error<T: DeserializeOwned>(&self) -> Option<T>
Attempt to deserialize the HTTP error response body as a specific type.
This is useful for APIs that return structured error responses.
§Example
use serde::Deserialize;
use zenwave::Client;
#[derive(Deserialize)]
struct ApiError {
code: String,
message: String,
}
match client.get("https://api.example.com/data") {
Err(e) => {
if let Some(api_err) = e.deserialize_http_error::<ApiError>() {
println!("API error: {} - {}", api_err.code, api_err.message);
}
}
Ok(builder) => {
let _resp = builder.await?;
}
}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()
Source§impl From<CacheError> for Error
impl From<CacheError> for Error
Source§fn from(err: CacheError) -> Self
fn from(err: CacheError) -> Self
Source§impl From<CookieError> for Error
impl From<CookieError> for Error
Source§fn from(err: CookieError) -> Self
fn from(err: CookieError) -> Self
Source§impl From<CookieErrorKind> for Error
impl From<CookieErrorKind> for Error
Source§fn from(source: CookieErrorKind) -> Self
fn from(source: CookieErrorKind) -> Self
Source§impl From<DownloadErrorKind> for Error
impl From<DownloadErrorKind> for Error
Source§fn from(source: DownloadErrorKind) -> Self
fn from(source: DownloadErrorKind) -> Self
Source§impl<H> From<FollowRedirectError<H>> for Error
impl<H> From<FollowRedirectError<H>> for Error
Source§fn from(err: FollowRedirectError<H>) -> Self
fn from(err: FollowRedirectError<H>) -> Self
Source§impl<E, M> From<MiddlewareError<E, M>> for Error
impl<E, M> From<MiddlewareError<E, M>> for Error
Source§fn from(err: MiddlewareError<E, M>) -> Self
fn from(err: MiddlewareError<E, M>) -> Self
Source§impl<H> From<OAuth2Error<H>> for Error
impl<H> From<OAuth2Error<H>> for Error
Source§fn from(err: OAuth2Error<H>) -> Self
fn from(err: OAuth2Error<H>) -> Self
Source§impl From<OAuth2ErrorKind> for Error
impl From<OAuth2ErrorKind> for Error
Source§fn from(source: OAuth2ErrorKind) -> Self
fn from(source: OAuth2ErrorKind) -> Self
Source§impl From<ProxyErrorKind> for Error
impl From<ProxyErrorKind> for Error
Source§fn from(source: ProxyErrorKind) -> Self
fn from(source: ProxyErrorKind) -> Self
Source§impl From<TimeoutError> for Error
impl From<TimeoutError> for Error
Source§fn from(_: TimeoutError) -> Self
fn from(_: TimeoutError) -> Self
Source§impl From<WebSocketError> for Error
impl From<WebSocketError> for Error
Source§fn from(err: WebSocketError) -> Self
fn from(err: WebSocketError) -> Self
Source§impl From<WebSocketErrorKind> for Error
impl From<WebSocketErrorKind> for Error
Source§fn from(source: WebSocketErrorKind) -> Self
fn from(source: WebSocketErrorKind) -> Self
Auto Trait Implementations§
impl !RefUnwindSafe for Error
impl !UnwindSafe for Error
impl Freeze 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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more