Skip to main content

mermaid_builder/shared/style_class/
error.rs

1//! Submodule defining the error enumeration which describes errors
2//! which may happen while creating style classes in Mermaid diagrams.
3
4use alloc::string::String;
5
6use thiserror::Error;
7
8use crate::shared::{StyleClass, style_class::StyleProperty};
9
10#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
11#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Error)]
12/// Enum representing the different types of errors that can occur when
13/// creating or using style classes in Mermaid diagrams.
14pub enum StyleClassError {
15    /// The name of the style class is empty.
16    #[error("Style class name cannot be empty.")]
17    EmptyName,
18    /// The style class was duplicated.
19    #[error("Duplicate style class: `{0}`")]
20    DuplicateClass(String),
21    /// The property was duplicated.
22    #[error("Duplicate property found: `{0}`")]
23    DuplicateProperty(StyleProperty),
24    /// The style class is unknown in the context of the diagram.
25    #[error("Unknown style class: `{}`", .0.name())]
26    UnknownClass(StyleClass),
27    /// The name of the style class is missing.
28    #[error("Style class name is missing.")]
29    MissingName,
30    /// The properties of the style class are missing.
31    #[error("Style class properties are missing.")]
32    MissingProperties,
33}