//! Error types for the HH library

use thiserror::Error;

/// Result type alias for HH operations
pub type Result<T> = std::result::Result<T, HHError>;

/// Error types that can occur in the HH library
#[derive(Error, Debug)]
pub enum HHError {
    /// HTTP request error
    #[error("HTTP request failed: {0}")]
    HttpError(#[from] reqwest::Error),

    /// HTML parsing error
    #[error("Failed to parse HTML: {0}")]
    ParseError(String),

    /// Data not found error
    #[error("Data not found: {0}")]
    NotFound(String),

    /// Invalid input error
    #[error("Invalid input: {0}")]
    InvalidInput(String),

    /// Generic error
    #[error("An error occurred: {0}")]
    Generic(String),
}

impl From<anyhow::Error> for HHError {
    fn from(err: anyhow::Error) -> Self {
        HHError::Generic(err.to_string())
    }
}
