use std::io;
#[derive(Debug)]
pub enum PdfError {
Io(io::Error),
Other(String),
}
impl PdfError {
pub fn other(msg: impl Into<String>) -> Self {
Self::Other(msg.into())
}
}
impl std::fmt::Display for PdfError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Io(e) => write!(f, "PDF I/O error: {e}"),
Self::Other(s) => write!(f, "PDF error: {s}"),
}
}
}
impl std::error::Error for PdfError {}
impl From<io::Error> for PdfError {
fn from(e: io::Error) -> Self {
Self::Io(e)
}
}
impl From<PdfError> for oxideav_core::Error {
fn from(e: PdfError) -> Self {
match e {
PdfError::Io(io) => oxideav_core::Error::Io(io),
PdfError::Other(msg) => oxideav_core::Error::invalid(msg),
}
}
}