use thiserror::Error;

pub type Result<T> = std::result::Result<T, EbookmError>;

#[derive(Debug, Error)]
pub enum EbookmError {
    #[error("failed to read file {path}: {source}")]
    Io {
        path: String,
        #[source]
        source: std::io::Error,
    },
    #[error("failed to parse manifest {path}: {source}")]
    ManifestParse {
        path: String,
        #[source]
        source: serde_yaml::Error,
    },
    #[error("manifest validation failed: {issues:?}")]
    Validation { issues: Vec<String> },
    #[error("network request failed for {url}: {source}")]
    Request {
        url: String,
        #[source]
        source: reqwest::Error,
    },
    #[error("invalid source path: {path}")]
    InvalidSourcePath { path: String },
    #[error("failed to parse URL {value}: {source}")]
    UrlParse {
        value: String,
        #[source]
        source: url::ParseError,
    },
    #[error("article extraction failed for {input}")]
    Extraction { input: String },
    #[error("EPUB generation failed: {message}")]
    Epub { message: String },
}
