Skip to main content

ferric_alpha_render/
error.rs

1use std::path::PathBuf;
2
3use thiserror::Error;
4
5pub type RenderResult<T> = Result<T, RenderError>;
6
7#[derive(Debug, Error)]
8pub enum RenderError {
9    #[error("invalid render option {option}: {reason}")]
10    InvalidOption {
11        option: &'static str,
12        reason: &'static str,
13    },
14
15    #[error("missing report table {id}")]
16    MissingTable { id: String },
17
18    #[error("missing column {column} in report table {table}")]
19    MissingColumn { table: String, column: String },
20
21    #[error("invalid column type for {table}.{column}: expected {expected}")]
22    InvalidColumnType {
23        table: String,
24        column: String,
25        expected: &'static str,
26    },
27
28    #[error("invalid render contract: {reason}")]
29    InvalidContract { reason: String },
30
31    #[error("render layout exceeds resource limits")]
32    LayoutOverflow,
33
34    #[error("render buffer allocation failed for {bytes} bytes")]
35    Allocation { bytes: usize },
36
37    #[error("rendered {format} output exceeds {limit} bytes")]
38    OutputTooLarge { format: &'static str, limit: usize },
39
40    #[error("{format} backend failed: {message}")]
41    Backend {
42        format: &'static str,
43        message: String,
44    },
45
46    #[error("PNG encoding failed: {message}")]
47    PngEncoding { message: String },
48
49    #[error("failed to write {path}: {source}")]
50    Io {
51        path: PathBuf,
52        #[source]
53        source: std::io::Error,
54    },
55}