Skip to main content

img_gen_spec/
error.rs

1/// Errors produced while validating or parsing image generation specifications.
2#[derive(Debug, thiserror::Error)]
3pub enum ImgGenSpecError {
4    /// Returned when a layer height would evaluate to zero.
5    #[error("Layer height cannot be zero")]
6    InvalidLayerHeight,
7
8    /// Returned when a CSS color string cannot be parsed.
9    #[error("Value '{value}' is not a valid CSS color ({reason})")]
10    InvalidCssColor {
11        /// The input value that failed to parse.
12        value: String,
13        /// The parser-provided failure reason.
14        reason: String,
15    },
16
17    /// Returned when a gradient specification cannot be converted into a gradient.
18    #[error("Failed to build color gradient: {reason}")]
19    InvalidGradientSpec {
20        /// The gradient builder failure reason.
21        reason: String,
22    },
23}
24
25/// A specialized result type for specification parsing and validation.
26pub type Result<T> = std::result::Result<T, ImgGenSpecError>;