pdf_rs/
error.rs

1use std::num::{ParseFloatError, ParseIntError};
2use std::string::FromUtf8Error;
3use thiserror::Error;
4
5/// Type alias for results that may contain errors.
6pub type Result<T> = std::result::Result<T, PDFError>;
7
8#[derive(Error, Debug)]
9pub enum PDFError {
10    #[error("Not support pdf version:{0}")]
11    NotSupportPDFVersion(String),
12    #[error("Invalid PDF document.")]
13    InvalidPDFDocument,
14    #[error("Xref table not found.")]
15    XrefTableNotFound,
16    #[error("Convert utf8 text error:{0}")]
17    UTF8Error(#[from] FromUtf8Error),
18    #[error("IO error:{0}")]
19    IOError(#[from] std::io::Error),
20    #[error("{0}")]
21    PDFParseError(&'static str),
22    #[error("{0}")]
23    PDFParseError0(String),
24    #[error("Xref entry:({0},{1}) not found")]
25    XrefEntryNotFound(u32,u16),
26    #[error("{0}")]
27    ObjectAttrMiss(&'static str),
28    #[error("End of file error")]
29    EOFError,
30    #[error("Seek exceed maximum of file size")]
31    SeekExceedError,
32    #[error("{0}")]
33    IntParseError(#[from] ParseIntError),
34    #[error("{0}")]
35    FloatParseError(#[from] ParseFloatError),
36    #[error("{0}")]
37    PDFObjectCastError(&'static str),
38    #[error("Illegal date format:{0}")]
39    IllegalDateFormat(String),
40    #[error("Page not found:{0}")]
41    PageNotFound(String),
42    #[error("Content stream type error")]
43    ContentStreamTypeError,
44    #[error("Not support filter:{0}")]
45    NotSupportFilter(String),
46}