curl_http_client/
error.rs

1use std::fmt::Debug;
2
3use async_curl::dep::curl;
4
5use crate::ExtendedHandler;
6
7/// Error type returned by failed curl HTTP requests.
8#[derive(Debug)]
9pub enum Error<C>
10where
11    C: ExtendedHandler + Debug + Send + 'static,
12{
13    Curl(curl::Error),
14    Http(String),
15    Perform(async_curl::error::Error<C>),
16    Other(String),
17}
18
19impl<C> std::fmt::Display for Error<C>
20where
21    C: ExtendedHandler + Debug + Send + 'static,
22{
23    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
24        match self {
25            Error::Curl(err) => write!(f, "{}", err),
26            Error::Http(err) => write!(f, "{}", err),
27            Error::Perform(err) => write!(f, "{}", err),
28            Error::Other(err) => write!(f, "{}", err),
29        }
30    }
31}
32
33impl<C> std::error::Error for Error<C> where C: ExtendedHandler + Debug + Send + 'static {}