1#[derive(Debug, thiserror::Error)]
2pub enum DurableError {
3 #[error("database error: {0}")]
4 Db(#[from] sea_orm::DbErr),
5
6 #[error("serialization error: {0}")]
7 Json(#[from] serde_json::Error),
8
9 #[error("{0}")]
10 Custom(String),
11
12 #[error("task locked by another worker: {0}")]
13 StepLocked(String),
14
15 #[error("timeout: {0}")]
16 Timeout(String),
17
18 #[error("workflow paused: {0}")]
19 Paused(String),
20
21 #[error("workflow cancelled: {0}")]
22 Cancelled(String),
23}
24
25impl DurableError {
26 pub fn custom(msg: impl Into<String>) -> Self {
27 Self::Custom(msg.into())
28 }
29
30 pub fn is_step_locked(&self) -> bool {
31 matches!(self, Self::StepLocked(_))
32 }
33
34 pub fn is_paused(&self) -> bool {
35 matches!(self, Self::Paused(_))
36 }
37
38 pub fn is_cancelled(&self) -> bool {
39 matches!(self, Self::Cancelled(_))
40 }
41}