1use thiserror::Error;
2
3#[derive(Debug, Error)]
7#[non_exhaustive]
8pub enum PdfError {
9 #[error("PDF parse error: {0}")]
11 Parse(String),
12
13 #[error("PDF serialize error: {0}")]
15 Serialize(String),
16
17 #[error("invalid field '{name}': {reason}")]
19 InvalidField { name: String, reason: String },
20
21 #[error("unsupported widget type: {0}")]
23 UnsupportedWidget(String),
24
25 #[error("image decode error: {0}")]
27 ImageDecode(String),
28
29 #[error("page {0} not found")]
31 PageNotFound(u32),
32
33 #[error("internal PDF error: {0}")]
35 Internal(String),
36}
37
38impl From<crate::lopdf_error::Error> for PdfError {
39 fn from(e: crate::lopdf_error::Error) -> Self {
40 PdfError::Internal(e.to_string())
41 }
42}