1use std::io;
8
9#[derive(Debug)]
11pub enum PdfError {
12 Io(io::Error),
16 Other(String),
19}
20
21impl PdfError {
22 pub fn other(msg: impl Into<String>) -> Self {
23 Self::Other(msg.into())
24 }
25}
26
27impl std::fmt::Display for PdfError {
28 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29 match self {
30 Self::Io(e) => write!(f, "PDF I/O error: {e}"),
31 Self::Other(s) => write!(f, "PDF error: {s}"),
32 }
33 }
34}
35
36impl std::error::Error for PdfError {}
37
38impl From<io::Error> for PdfError {
39 fn from(e: io::Error) -> Self {
40 Self::Io(e)
41 }
42}
43
44impl From<PdfError> for oxideav_core::Error {
45 fn from(e: PdfError) -> Self {
46 match e {
47 PdfError::Io(io) => oxideav_core::Error::Io(io),
48 PdfError::Other(msg) => oxideav_core::Error::invalid(msg),
49 }
50 }
51}