1use thiserror::Error;
4use uuid::Uuid;
5
6#[derive(Debug, Error)]
8pub enum FlowError {
9 #[error("invalid flow definition: {0}")]
11 InvalidDefinition(String),
12
13 #[error("flow graph contains a cycle")]
15 CyclicGraph,
16
17 #[error("unknown node id: {0}")]
19 UnknownNode(String),
20
21 #[error("node '{node_id}' failed during execution '{execution_id}': {reason}")]
23 NodeFailed {
24 node_id: String,
25 execution_id: Uuid,
26 reason: String,
27 },
28
29 #[error("execution was terminated")]
31 Terminated,
32
33 #[error("execution not found: {0}")]
35 ExecutionNotFound(Uuid),
36
37 #[error("flow not found: {0}")]
39 FlowNotFound(String),
40
41 #[error("cannot {action} a {from} execution")]
43 InvalidTransition { action: String, from: String },
44
45 #[error("json error: {0}")]
47 Json(#[from] serde_json::Error),
48
49 #[error("internal error: {0}")]
51 Internal(String),
52}
53
54pub type Result<T> = std::result::Result<T, FlowError>;