Skip to main content

mermaid_builder/errors/
node_error.rs

1//! Submodule providing an enumeration of possible errors that can occur in the
2//! nodes of diagrams in Mermaid syntax.
3
4use alloc::string::String;
5
6use thiserror::Error;
7
8#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Error)]
9#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
10/// Enum representing errors related to nodes in Mermaid diagrams.
11pub enum NodeError {
12    /// The provided node label is empty.
13    #[error("Node label cannot be empty.")]
14    EmptyLabel,
15    /// The provided node ID is empty.
16    #[error("Node ID cannot be empty.")]
17    EmptyId,
18    /// The provided node ID contains invalid characters.
19    #[error("Node ID `{0}` contains invalid characters.")]
20    InvalidId(String),
21    /// The provided node already exists in the diagram.
22    #[error("Node `{0}` already exists.")]
23    DuplicateNode(String),
24    /// The node ID is missing.
25    #[error("Node ID is missing.")]
26    MissingId,
27    /// The node label is missing.
28    #[error("Node label is missing.")]
29    MissingLabel,
30    /// The subnodes are missing (required for subgraph with direction).
31    #[error("Subnodes are missing.")]
32    MissingSubnodes,
33}