pdf_converter/
error.rs

1//! Error types for PDF conversion operations
2
3/// Result type alias for PDF conversion operations
4pub type Result<T> = std::result::Result<T, PdfError>;
5
6/// Error types that can occur during PDF conversion
7#[derive(Debug, thiserror::Error)]
8pub enum PdfError {
9    /// IO error occurred
10    #[error("IO error: {0}")]
11    Io(#[from] std::io::Error),
12
13    /// Image processing error
14    #[error("Image error: {0}")]
15    Image(#[from] image::ImageError),
16
17    /// PDF generation error
18    #[error("PDF error: {0}")]
19    Pdf(#[from] printpdf::Error),
20
21    /// No images found in the specified folder
22    #[error("No images found in folder: {0}")]
23    NoImagesFound(String),
24
25    /// Invalid folder path
26    #[error("Invalid folder path: {0}")]
27    InvalidPath(String),
28
29    /// Custom error with message
30    #[error("{0}")]
31    Custom(String),
32}
33
34impl PdfError {
35    /// Create a custom error with a message
36    pub fn custom<S: Into<String>>(message: S) -> Self {
37        Self::Custom(message.into())
38    }
39}