use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[error("Error building the request: {0}")]
RequestError(String),
#[error("Error getting the response: {0}")]
ResponseError(String),
#[error("Authentication error")]
Unauthorized,
#[error("Unexpected error: {0}" )]
Unexpected(String),
}
impl Error {
pub fn is_unauthorized(&self) -> bool {
matches!(self, Error::Unauthorized)
}
pub fn is_request_error(&self) -> bool {
matches!(self, Error::RequestError(_))
}
pub fn is_response_error(&self) -> bool {
matches!(self, Error::ResponseError(_))
}
pub fn is_unexpected(&self) -> bool {
matches!(self, Error::Unexpected(_))
}
}