1use std::io;
2use thiserror::Error;
3
4pub type PdfResult<T> = Result<T, PdfError>;
6
7#[derive(Debug, Error)]
9pub enum PdfError {
10 #[error("I/O error: {0}")]
11 Io(#[from] io::Error),
12
13 #[error("Parse error at offset {offset}: {message}")]
14 Parse { offset: usize, message: String },
15
16 #[error("Invalid PDF format: {0}")]
17 InvalidFormat(String),
18
19 #[error("Missing required dictionary entry: {0}")]
20 MissingEntry(String),
21
22 #[error("Unexpected object type: expected {expected}, found {found}")]
23 TypeMismatch {
24 expected: &'static str,
25 found: &'static str,
26 },
27
28 #[error("Invalid object reference: {0:?}")]
29 InvalidReference(crate::cos::ObjectId),
30
31 #[error("Stream decompression or compression error: {0}")]
32 StreamCompression(String),
33
34 #[error("Font error: {0}")]
35 Font(String),
36
37 #[error("Image processing error: {0}")]
38 Image(String),
39
40 #[error("Cryptography/Security error: {0}")]
41 Crypto(String),
42
43 #[error("Digital signature error: {0}")]
44 Signature(String),
45
46 #[error("Page operation error: {0}")]
47 PageOperation(String),
48
49 #[error("Unsupported feature: {0}")]
50 Unsupported(String),
51}