use thiserror::Error;

#[derive(Debug, Error)]
pub enum CpdfError {
    #[error("I/O error: {0}")]
    Io(#[from] std::io::Error),
    #[error("Parse error: {0}")]
    Parse(String),
    #[error("Invalid page range: {0}")]
    InvalidRange(String),
    #[error("Encryption error: {0}")]
    Encryption(String),
    #[error("Not found: {0}")]
    NotFound(String),
    #[error("Unsupported: {0}")]
    Unsupported(String),
    #[error("Invalid argument: {0}")]
    InvalidArgument(String),
}

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

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn error_display_includes_message() {
        let e = CpdfError::Parse("bad xref".into());
        assert!(e.to_string().contains("bad xref"));
    }
}
