potato_workflow/workflow/
error.rs1use potato_util::UtilError;
2use pyo3::exceptions::PyRuntimeError;
3use pyo3::PyErr;
4use thiserror::Error;
5use tracing::error;
6
7#[derive(Error, Debug)]
8pub enum WorkflowError {
9 #[error("Error: {0}")]
10 Error(String),
11
12 #[error("Max retries exceeded for task: {0}")]
13 MaxRetriesExceeded(String),
14
15 #[error("Task id already exists: {0}")]
16 TaskAlreadyExists(String),
17
18 #[error("Task dependency not found in registered tasks: {0}")]
19 DependencyNotFound(String),
20
21 #[error("Task not cannot depend on itself: {0}")]
22 TaskDependsOnItself(String),
23
24 #[error(transparent)]
25 UtilError(#[from] UtilError),
26
27 #[error("Failed to create runtime: {0}")]
28 RuntimeError(String),
29
30 #[error("Invalid output type provided for task: {0}")]
31 InvalidOutputType(String),
32
33 #[error(transparent)]
34 SerializationError(#[from] serde_json::Error),
35
36 #[error("Failed to acquire lock on workflow")]
37 LockAcquireError,
38
39 #[error("Failed to acquire read lock on workflow")]
40 ReadLockAcquireError,
41
42 #[error("Failed to acquire write lock on workflow")]
43 WriteLockAcquireError,
44
45 #[error(transparent)]
46 AgentError(#[from] potato_agent::AgentError),
47}
48
49impl From<WorkflowError> for PyErr {
50 fn from(err: WorkflowError) -> PyErr {
51 let msg = err.to_string();
52 error!("{}", msg);
53 PyRuntimeError::new_err(msg)
54 }
55}
56
57impl From<PyErr> for WorkflowError {
58 fn from(err: PyErr) -> Self {
59 WorkflowError::Error(err.to_string())
60 }
61}