kanban_core/graph/
error.rs1use thiserror::Error;
2
3#[derive(Error, Debug, PartialEq, Eq, Clone)]
10pub enum GraphError {
11 #[error("operation would create a cycle")]
12 Cycle,
13 #[error("self-reference is not allowed")]
14 SelfReference,
15 #[error("edge not found")]
16 EdgeNotFound,
17 #[error("an active edge with the same endpoints already exists")]
23 Duplicate,
24}
25
26#[cfg(test)]
27mod tests {
28 use super::*;
29
30 #[test]
31 fn test_graph_error_cycle_displays_expected_message() {
32 assert_eq!(
33 GraphError::Cycle.to_string(),
34 "operation would create a cycle"
35 );
36 }
37
38 #[test]
39 fn test_graph_error_self_reference_displays_expected_message() {
40 assert_eq!(
41 GraphError::SelfReference.to_string(),
42 "self-reference is not allowed"
43 );
44 }
45
46 #[test]
47 fn test_graph_error_edge_not_found_displays_expected_message() {
48 assert_eq!(GraphError::EdgeNotFound.to_string(), "edge not found");
49 }
50
51 #[test]
52 fn test_graph_error_supports_equality() {
53 assert_eq!(GraphError::Cycle, GraphError::Cycle);
54 assert_ne!(GraphError::Cycle, GraphError::SelfReference);
55 }
56}