tinted_builder/
error.rs

1use ribboncurls::RibboncurlsError;
2use thiserror::Error;
3
4/// An error type representing the various errors that can occur when using tinted-builder
5///
6/// This error type is non-exhaustive, meaning additional variants may be added in future versions without
7/// it being considered a breaking change. The enum variants cover a range of possible issues that might
8/// arise during the processing of color schemes, including missing properties, deserialization errors,
9/// and rendering issues.
10#[non_exhaustive]
11#[derive(Error, Debug)]
12pub enum TintedBuilderError {
13    /// Error indicating that a required property in the scheme is missing.
14    ///
15    /// This variant is used when a necessary property for the scheme's configuration is not found.
16    #[error("missing scheme property: {0}")]
17    SchemeMissingProperty(String),
18
19    /// Error that occurs when YAML deserialization fails.
20    ///
21    /// This variant wraps the `serde_yaml::Error` and is used when there is an issue converting
22    /// a YAML string into the corresponding Rust data structure.
23    #[error("unable to deserialize yaml")]
24    YamlDeserialize(#[from] serde_yaml::Error),
25
26    /// Error that occurs during rendering using Ribboncurls.
27    ///
28    /// This variant wraps the `RibboncurlsError` and is used when an error is encountered while
29    /// rendering a template or other content using Ribboncurls.
30    #[error("unable to render")]
31    RibboncurlsRender(#[from] RibboncurlsError),
32
33    /// Error that occurs when a string slice cannot be converted to an integer with the given base.
34    ///
35    /// This variant wraps `std::num::ParseIntError` and is used when a string slice, such as a color
36    /// value in hexadecimal format, fails to parse correctly.
37    #[error("unable to convert string slice to integer with given base")]
38    ColorRadix(#[from] std::num::ParseIntError),
39
40    /// Error indicating that a hex color input is not formatted correctly.
41    ///
42    /// This variant is used when a color string that is expected to be in hex format does not match
43    /// the expected format.
44    #[error("hex input is not formatted correctly")]
45    HexInputFormat,
46
47    /// Error indicating that an invalid scheme variant was provided.
48    ///
49    /// This variant is used when an input string does not correspond to any valid scheme variant,
50    /// such as "dark" or "light".
51    #[error("invalid scheme variant: {0}")]
52    InvalidSchemeVariant(String),
53
54    /// Error indicating that an invalid scheme system was provided.
55    ///
56    /// This variant is used when an input string does not correspond to any valid scheme system
57    #[error("invalid scheme system: {0}")]
58    InvalidSchemeSystem(String),
59}