1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, FlowError>;
5
6#[derive(Debug, Error)]
8pub enum FlowError {
9 #[error("workflow run not found: {0}")]
10 RunNotFound(String),
11
12 #[error("workflow run {0} is already terminal")]
13 RunTerminal(String),
14
15 #[error("workflow run id is invalid: {0}")]
16 InvalidRunId(String),
17
18 #[error("workflow run {run_id} conflicts with existing run: {reason}")]
19 RunConflict { run_id: String, reason: String },
20
21 #[error("non-deterministic workflow replay for run {run_id}: {reason}")]
22 NonDeterministic { run_id: String, reason: String },
23
24 #[error(
25 "event sequence conflict for run {run_id}: expected {expected_sequence}, actual {actual_sequence}"
26 )]
27 EventConflict {
28 run_id: String,
29 expected_sequence: u64,
30 actual_sequence: u64,
31 },
32
33 #[error("active hook token not found: {0}")]
34 HookTokenNotFound(String),
35
36 #[error("workflow task lease is no longer active: {0}")]
37 LeaseLost(String),
38
39 #[error(
40 "active hook token {token:?} is already used by run {existing_run_id} hook {existing_hook_id}"
41 )]
42 HookTokenConflict {
43 token: String,
44 existing_run_id: String,
45 existing_hook_id: String,
46 },
47
48 #[error("invalid workflow definition: {0}")]
49 InvalidWorkflow(String),
50
51 #[error("invalid state transition: {0}")]
52 InvalidTransition(String),
53
54 #[error("invalid worker configuration: {0}")]
55 InvalidWorkerConfiguration(String),
56
57 #[error("task manager error: {0}")]
58 TaskManagement(String),
59
60 #[error("event store error: {0}")]
61 Store(String),
62
63 #[error("runtime error: {0}")]
64 Runtime(String),
65
66 #[error("serialization error: {0}")]
67 Serialization(#[from] serde_json::Error),
68
69 #[error("io error: {0}")]
70 Io(#[from] std::io::Error),
71
72 #[error("workflow replay exceeded {0} iterations")]
73 ReplayLimitExceeded(usize),
74}