use std::path::PathBuf;

#[derive(Debug, thiserror::Error)]
pub enum Error {
    #[error("I/O error on {path}: {source}")]
    Io {
        path: PathBuf,
        source: std::io::Error,
    },

    #[error("pattern database parse error at line {line}: {message}")]
    PatternParse { line: usize, message: String },

    #[error("unsupported archive format: {path}")]
    UnsupportedArchive { path: PathBuf },

    #[error("extraction failed for {path}: {message}")]
    Extraction { path: PathBuf, message: String },

    #[error("cycle detected in archive graph: {path}")]
    ArchiveCycle { path: PathBuf },

    #[error("encoding detection failed for {path}")]
    Encoding { path: PathBuf },

    #[error("{0}")]
    Other(String),
}

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