graph_sp/core/
error.rs

1//! Error types for the graph execution engine.
2
3use thiserror::Error;
4
5/// Result type for graph operations
6pub type Result<T> = std::result::Result<T, GraphError>;
7
8/// Errors that can occur during graph operations
9#[derive(Error, Debug)]
10pub enum GraphError {
11    /// Node not found in the graph
12    #[error("Node not found: {0}")]
13    NodeNotFound(String),
14
15    /// Edge not found in the graph
16    #[error("Edge not found: from {from} to {to}")]
17    EdgeNotFound { from: String, to: String },
18
19    /// Cycle detected in the graph
20    #[error("Cycle detected in graph involving node: {0}")]
21    CycleDetected(String),
22
23    /// Invalid graph structure
24    #[error("Invalid graph structure: {0}")]
25    InvalidGraph(String),
26
27    /// Port validation error
28    #[error("Port validation error: {0}")]
29    PortError(String),
30
31    /// Execution error
32    #[error("Execution error: {0}")]
33    ExecutionError(String),
34
35    /// Data type mismatch
36    #[error("Data type mismatch: expected {expected}, got {actual}")]
37    TypeMismatch { expected: String, actual: String },
38
39    /// Missing required input
40    #[error("Missing required input for node {node}: {port}")]
41    MissingInput { node: String, port: String },
42
43    /// Generic error
44    #[error("{0}")]
45    Other(String),
46}