use core::error::Error;
use core::fmt;
#[derive(Debug)]
pub enum ApiErr {
Reqwest(reqwest::Error),
UnDeserializeable(String),
Other(String),
}
impl From<reqwest::Error> for ApiErr {
fn from(e: reqwest::Error) -> Self {
Self::Reqwest(e)
}
}
impl fmt::Display for ApiErr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Reqwest(e) => write!(f, "Reqwest error: {e}"),
Self::UnDeserializeable(e) => write!(f, "Serde error: {e}"),
ApiErr::Other(e) => write!(f, "Other error: {e}"),
}
}
}
impl Error for ApiErr {}
pub type ApiResult<T> = Result<T, ApiErr>;