use std::path::PathBuf;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum RenderError {
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("PDF parse error: {0}")]
Parse(String),
#[error("page index {index} out of bounds (total {total})")]
InvalidPage {
index: usize,
total: usize,
},
#[error("render backend '{name}' is not available: {reason}")]
BackendUnavailable {
name: &'static str,
reason: String,
},
#[cfg(feature = "pdfium")]
#[error("pdfium library error: {0}")]
Pdfium(String),
#[error("image encoding error: {0}")]
ImageEncode(String),
#[error("DPI {requested} exceeds backend maximum {max}")]
DpiExceeded {
requested: u32,
max: u32,
},
#[error("invalid output path: {0}")]
InvalidOutput(PathBuf),
#[error("{0}")]
Other(String),
}
pub type Result<T, E = RenderError> = std::result::Result<T, E>;