1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum Error {
5 #[error("workflow not found: {0}")]
6 WorkflowNotFound(String),
7
8 #[error("execution not found: {0}")]
9 ExecutionNotFound(String),
10
11 #[error("node not found: {node_id} in workflow {workflow_id}")]
12 NodeNotFound {
13 workflow_id: String,
14 node_id: String,
15 },
16
17 #[error("invalid state transition: {current:?} → {requested:?}")]
18 InvalidTransition {
19 current: crate::WorkflowStatus,
20 requested: crate::WorkflowStatus,
21 },
22
23 #[error("schema validation failed: {0}")]
24 SchemaValidation(String),
25
26 #[error("policy violation: {0}")]
27 PolicyViolation(String),
28
29 #[error("budget exceeded: {kind} limit reached (limit={limit}, current={current})")]
30 BudgetExceeded {
31 kind: String,
32 limit: u64,
33 current: u64,
34 },
35
36 #[error("storage error: {0}")]
37 Storage(String),
38
39 #[error("serialization error: {0}")]
40 Serialization(#[from] serde_json::Error),
41}
42
43pub type Result<T> = std::result::Result<T, Error>;