use std::fmt;
#[derive(Debug)]
pub enum BrowserError {
Playwright(String),
Navigation(String),
Timeout(String),
PagePool(String),
Config(String),
Other(String),
}
impl fmt::Display for BrowserError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Playwright(e) => write!(f, "playwright error: {e}"),
Self::Navigation(e) => write!(f, "navigation error: {e}"),
Self::Timeout(e) => write!(f, "timeout: {e}"),
Self::PagePool(e) => write!(f, "page pool error: {e}"),
Self::Config(e) => write!(f, "config error: {e}"),
Self::Other(e) => write!(f, "{e}"),
}
}
}
impl std::error::Error for BrowserError {}
impl From<playwright_rs::Error> for BrowserError {
fn from(e: playwright_rs::Error) -> Self {
Self::Playwright(e.to_string())
}
}
pub type Result<T> = std::result::Result<T, BrowserError>;