Skip to main content

mermaid_builder/errors/
edge_error.rs

1//! Submodule providing an enumeration of possible errors that can occur in the
2//! edges of diagrams in Mermaid syntax.
3
4use alloc::string::String;
5
6use thiserror::Error;
7
8use crate::shared::ArrowShape;
9
10#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Error)]
11#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
12/// Enum representing errors related to edges in Mermaid diagrams.
13pub enum EdgeError {
14    /// The provided edge label is empty.
15    #[error("Edge label cannot be empty.")]
16    EmptyLabel,
17    /// The provided left arrow shape is not compatible with the diagram.
18    #[error("Incompatible left arrow shape: `{}`", .0.left())]
19    IncompatibleLeftArrowShape(ArrowShape),
20    /// The provided right arrow shape is not compatible with the diagram.
21    #[error("Incompatible right arrow shape: `{}`", .0.right())]
22    IncompatibleRightArrowShape(ArrowShape),
23    /// The provided source node does not exist in the diagram.
24    #[error("Source node not found: `{0}`")]
25    SourceNodeNotFound(String),
26    /// The provided destination node does not exist in the diagram.
27    #[error("Destination node not found: `{0}`")]
28    DestinationNodeNotFound(String),
29    /// The source node is missing.
30    #[error("Source node is missing.")]
31    MissingSource,
32    /// The destination node is missing.
33    #[error("Destination node is missing.")]
34    MissingDestination,
35    /// The edge ID is missing.
36    #[error("Edge ID is missing.")]
37    MissingId,
38    /// The edge length is invalid (must be > 0).
39    #[error("Edge length must be greater than 0.")]
40    InvalidLength,
41}