Skip to main content

pdfcrate/
error.rs

1//! Error types for pdfcrate
2
3use thiserror::Error;
4
5/// Result type alias for pdfcrate operations
6pub type Result<T> = std::result::Result<T, Error>;
7
8/// Error types for PDF operations
9#[derive(Error, Debug)]
10pub enum Error {
11    /// IO error
12    #[error("IO error: {0}")]
13    Io(#[from] std::io::Error),
14
15    /// Parse error
16    #[error("Parse error: {message} at position {position}")]
17    Parse { message: String, position: usize },
18
19    /// Invalid PDF structure
20    #[error("Invalid PDF structure: {0}")]
21    InvalidStructure(String),
22
23    /// Missing required object
24    #[error("Missing required object: {0}")]
25    MissingObject(String),
26
27    /// Invalid object type
28    #[error("Invalid object type: expected {expected}, got {actual}")]
29    InvalidObjectType { expected: String, actual: String },
30
31    /// Unsupported feature
32    #[error("Unsupported feature: {0}")]
33    Unsupported(String),
34
35    /// SVG error
36    #[error("SVG error: {0}")]
37    Svg(String),
38
39    /// Encoding error
40    #[error("Encoding error: {0}")]
41    Encoding(String),
42
43    /// Compression error
44    #[error("Compression error: {0}")]
45    Compression(String),
46
47    /// Font error
48    #[error("Font error: {0}")]
49    Font(String),
50
51    /// Image error
52    #[error("Image error: {0}")]
53    Image(String),
54}