pub enum FetchError {
Type(TypeError),
Network(NetworkError),
Abort(AbortError),
}Expand description
The main error type for fetch operations.
This enum encompasses all possible errors that can occur during fetch operations. It provides a unified error type while preserving the specific error information.
§Variants
Type- Type-related errors (invalid arguments, validation failures)Network- Network-related errors (connection, DNS, TLS failures)Abort- Request was aborted via abort signal
§Examples
use fetchttp::*;
async fn handle_fetch_error() {
match fetch("https://example.com", None).await {
Ok(response) => {
println!("Success: {}", response.status());
}
Err(FetchError::Type(e)) => {
eprintln!("Type error: {}", e);
}
Err(FetchError::Network(e)) => {
eprintln!("Network error: {}", e);
}
Err(FetchError::Abort(e)) => {
eprintln!("Request aborted: {}", e);
}
}
}Variants§
Type(TypeError)
Type-related error (invalid arguments, validation failures)
Network(NetworkError)
Network-related error (connection, DNS, TLS failures)
Abort(AbortError)
Request was aborted
Trait Implementations§
Source§impl Debug for FetchError
impl Debug for FetchError
Source§impl Display for FetchError
impl Display for FetchError
Source§impl Error for FetchError
impl Error for FetchError
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()
Source§impl From<AbortError> for FetchError
impl From<AbortError> for FetchError
Source§fn from(err: AbortError) -> Self
fn from(err: AbortError) -> Self
Converts to this type from the input type.
Source§impl From<Error> for FetchError
impl From<Error> for FetchError
Source§impl From<Error> for FetchError
impl From<Error> for FetchError
Source§impl From<Error> for FetchError
impl From<Error> for FetchError
Source§impl From<Error> for FetchError
impl From<Error> for FetchError
Source§impl From<NetworkError> for FetchError
impl From<NetworkError> for FetchError
Source§fn from(err: NetworkError) -> Self
fn from(err: NetworkError) -> Self
Converts to this type from the input type.
Source§impl From<ParseError> for FetchError
impl From<ParseError> for FetchError
Source§fn from(_: ParseError) -> Self
fn from(_: ParseError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for FetchError
impl RefUnwindSafe for FetchError
impl Send for FetchError
impl Sync for FetchError
impl Unpin for FetchError
impl UnwindSafe for FetchError
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