article_scraper 2.3.1

Scrap article contents from the web. Powered by fivefilters full text feed configurations & mozilla readability.
Documentation
use thiserror::Error;

#[derive(Error, Debug)]
pub enum ScraperError {
    #[error("Configerror {0}")]
    Config(#[from] ConfigError),
    #[error("ImageDownloadError {0}")]
    Image(#[from] ImageDownloadError),
    #[error("FullTextParserError {0}")]
    Scrap(#[from] FullTextParserError),
}

#[derive(Error, Debug)]
pub enum ConfigError {
    #[error("IO error")]
    IO(#[from] std::io::Error),
    #[error("Unknown Error")]
    Unknown,
}

#[derive(Error, Debug)]
pub enum ImageDownloadError {
    #[error("Parsing the supplied html string failed")]
    HtmlParse,
    #[error("Scaling down a downloaded image failed")]
    ImageScale,
    #[error("Downloading the parent element of an image failed")]
    ParentDownload,
    #[error("Generating image name failed")]
    ImageName,
    #[error("Getting the content-length property failed")]
    ContentLength,
    #[error("Content-type suggest no image")]
    ContentType,
    #[error("Http error")]
    Http,
    #[error("IO error")]
    IO,
    #[error("Invalid URL")]
    InvalidUrl(#[from] url::ParseError),
    #[error("Download timed out")]
    Timeout,
    #[error("Download was cancelled")]
    Cancelled,
    #[error("Unknown Error")]
    Unknown,
}

impl From<reqwest::Error> for ImageDownloadError {
    fn from(_value: reqwest::Error) -> Self {
        Self::Http
    }
}

#[derive(Error, Debug)]
pub enum FullTextParserError {
    #[error("libXml Error")]
    Xml,
    #[error("No content found")]
    Scrape,
    #[error("Url Error")]
    Url(#[from] url::ParseError),
    #[error("Http request failed")]
    Http,
    #[error("Config Error")]
    Config,
    #[error("IO Error")]
    IO,
    #[error("Content-type suggest no html")]
    ContentType,
    #[error("Invalid UTF8 Text")]
    Utf8(#[from] std::str::Utf8Error),
    #[error("Readability Error")]
    Readability,
    #[error("Unknown Error")]
    Unknown,
}