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(
37 "active hook token {token:?} is already used by run {existing_run_id} hook {existing_hook_id}"
38 )]
39 HookTokenConflict {
40 token: String,
41 existing_run_id: String,
42 existing_hook_id: String,
43 },
44
45 #[error("invalid workflow definition: {0}")]
46 InvalidWorkflow(String),
47
48 #[error("invalid state transition: {0}")]
49 InvalidTransition(String),
50
51 #[error("event store error: {0}")]
52 Store(String),
53
54 #[error("runtime error: {0}")]
55 Runtime(String),
56
57 #[error("serialization error: {0}")]
58 Serialization(#[from] serde_json::Error),
59
60 #[error("io error: {0}")]
61 Io(#[from] std::io::Error),
62
63 #[error("workflow replay exceeded {0} iterations")]
64 ReplayLimitExceeded(usize),
65}