use crate::url_store::UrlError;
use derive_more::{From, derive::Display};
use std::num::ParseIntError;
pub type Result<T> = core::result::Result<T, Error>;
#[derive(Debug, From, Display)]
pub enum Error {
#[from]
#[display("{_0}")]
Custom(String),
#[from]
Url(UrlError),
#[from]
Chrono(chrono::ParseError),
#[from]
SerdeJson(serde_json::Error),
#[from]
Reqwest(reqwest::Error),
#[from]
Regex(regex::Error),
#[from]
Io(std::io::Error),
#[from]
Parse(ParseIntError),
}
impl PartialEq for Error {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Error::Custom(a), Error::Custom(b)) => a == b,
(a, b) => a.to_string() == b.to_string(),
}
}
}
impl From<&str> for Error {
fn from(val: &str) -> Self {
Self::Custom(val.to_string())
}
}
impl std::error::Error for Error {}