Skip to main content

hyper_render/
error.rs

1//! Error types for hyper-render.
2
3use thiserror::Error;
4
5/// Result type alias for hyper-render operations.
6pub type Result<T> = std::result::Result<T, Error>;
7
8/// Errors that can occur during HTML rendering.
9#[derive(Debug, Error)]
10pub enum Error {
11    /// The requested output format feature is not enabled.
12    #[error("output format '{0}' is not enabled; enable the '{0}' feature in Cargo.toml")]
13    FormatNotEnabled(&'static str),
14
15    /// Invalid configuration values.
16    #[error("invalid configuration: {0}")]
17    InvalidConfig(String),
18
19    /// Failed to render to PNG format.
20    #[error("PNG rendering failed: {0}")]
21    PngRender(String),
22
23    /// Failed to render to PDF format.
24    #[error("PDF rendering failed: {0}")]
25    PdfRender(String),
26
27    /// Failed to encode PNG image.
28    #[error("PNG encoding failed: {0}")]
29    PngEncode(String),
30
31    /// Failed to create PDF document.
32    #[error("PDF creation failed: {0}")]
33    PdfCreate(String),
34
35    /// Layout computation failed.
36    #[error("layout computation failed: {0}")]
37    Layout(String),
38
39    /// Font loading or rendering failed.
40    #[error("font error: {0}")]
41    Font(String),
42
43    /// I/O error occurred.
44    #[error("I/O error: {0}")]
45    Io(#[from] std::io::Error),
46}