use boa_cat::Error as EngineError;
use css_cat::Error as CssError;
use html_cat::Error as HtmlError;
use web_api_cat::Error as WebApiError;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Error {
Html(HtmlError),
Css(CssError),
Engine(EngineError),
WebApi(WebApiError),
}
impl From<HtmlError> for Error {
fn from(value: HtmlError) -> Self {
Self::Html(value)
}
}
impl From<CssError> for Error {
fn from(value: CssError) -> Self {
Self::Css(value)
}
}
impl From<EngineError> for Error {
fn from(value: EngineError) -> Self {
Self::Engine(value)
}
}
impl From<WebApiError> for Error {
fn from(value: WebApiError) -> Self {
Self::WebApi(value)
}
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Html(e) => write!(f, "html error: {e}"),
Self::Css(e) => write!(f, "css error: {e}"),
Self::Engine(e) => write!(f, "engine error: {e}"),
Self::WebApi(e) => write!(f, "web-api error: {e}"),
}
}
}
impl std::error::Error for Error {}