Skip to main content

ruvector_delta_graph/
error.rs

1//! Error types for graph delta operations
2
3use std::fmt;
4
5/// Result type for graph delta operations
6pub type Result<T> = std::result::Result<T, GraphDeltaError>;
7
8/// Errors that can occur during graph delta operations
9#[derive(Debug, Clone)]
10pub enum GraphDeltaError {
11    /// Node not found
12    NodeNotFound(String),
13    /// Edge not found
14    EdgeNotFound(String),
15    /// Invalid operation
16    InvalidOperation(String),
17    /// Delta error
18    DeltaError(String),
19    /// Cycle detected
20    CycleDetected,
21    /// Constraint violation
22    ConstraintViolation(String),
23}
24
25impl fmt::Display for GraphDeltaError {
26    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27        match self {
28            Self::NodeNotFound(id) => write!(f, "Node not found: {}", id),
29            Self::EdgeNotFound(id) => write!(f, "Edge not found: {}", id),
30            Self::InvalidOperation(msg) => write!(f, "Invalid operation: {}", msg),
31            Self::DeltaError(msg) => write!(f, "Delta error: {}", msg),
32            Self::CycleDetected => write!(f, "Cycle detected in graph"),
33            Self::ConstraintViolation(msg) => write!(f, "Constraint violation: {}", msg),
34        }
35    }
36}
37
38impl std::error::Error for GraphDeltaError {}