1use crate::interrupt::Interrupt;
4use thiserror::Error;
5
6pub type Result<T> = std::result::Result<T, GraphError>;
8
9#[derive(Error, Debug)]
11pub enum GraphError {
12 #[error("Invalid graph structure: {0}")]
14 InvalidGraph(String),
15
16 #[error("Node not found: {0}")]
18 NodeNotFound(String),
19
20 #[error("Edge target not found: {0}")]
22 EdgeTargetNotFound(String),
23
24 #[error("No entry point defined (missing edge from START)")]
26 NoEntryPoint,
27
28 #[error("Recursion limit exceeded: {0} steps")]
30 RecursionLimitExceeded(usize),
31
32 #[error("Execution interrupted: {0:?}")]
34 Interrupted(Box<InterruptedExecution>),
35
36 #[error("Node '{node}' execution failed: {message}")]
38 NodeExecutionFailed { node: String, message: String },
39
40 #[error("State serialization error: {0}")]
42 SerializationError(String),
43
44 #[error("Checkpoint error: {0}")]
46 CheckpointError(String),
47
48 #[error("Router returned unknown target: {0}")]
50 UnknownRouteTarget(String),
51
52 #[error("ADK error: {0}")]
54 AdkError(#[from] adk_core::AdkError),
55
56 #[error("IO error: {0}")]
58 IoError(#[from] std::io::Error),
59
60 #[error("JSON error: {0}")]
62 JsonError(#[from] serde_json::Error),
63
64 #[cfg(feature = "sqlite")]
66 #[error("Database error: {0}")]
67 DatabaseError(#[from] sqlx::Error),
68}
69
70#[derive(Debug, Clone)]
72pub struct InterruptedExecution {
73 pub thread_id: String,
75 pub checkpoint_id: String,
77 pub interrupt: Interrupt,
79 pub state: crate::state::State,
81 pub step: usize,
83}
84
85impl InterruptedExecution {
86 pub fn new(
88 thread_id: String,
89 checkpoint_id: String,
90 interrupt: Interrupt,
91 state: crate::state::State,
92 step: usize,
93 ) -> Self {
94 Self { thread_id, checkpoint_id, interrupt, state, step }
95 }
96}