use hayro::hayro_syntax::LoadPdfError;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum PdfError {
#[error("could not parse PDF document")]
Parse,
#[error("PDF document is encrypted (password-protected)")]
Encrypted,
#[error("page {index} is out of range (document has {count} page(s))")]
PageOutOfRange {
index: usize,
count: usize,
},
}
impl PdfError {
pub(crate) fn from_load(err: LoadPdfError) -> Self {
match err {
LoadPdfError::Decryption(_) => Self::Encrypted,
LoadPdfError::Invalid => Self::Parse,
}
}
}