1use std::error::Error;
2
3use thiserror::Error;
4
5use crate::component::Id;
6use crate::connection::Connection;
7use crate::ports::PortId;
8
9
10pub type Result<T> = std::result::Result<T, FlowError>;
11pub type RunResult<T> = std::result::Result<T, Box<dyn Error + Send + Sync>>;
12
13#[derive(Debug, Error)]
14pub enum FlowError {
15 #[error("Component with id = {id:?} already exist")]
16 ComponentAlreadyExist { id: Id },
17
18 #[error("Not found a component with id = {id:?}")]
19 ComponentNotFound { id: Id },
20
21 #[error("Connection = {connection:?} already exist")]
22 ConnectionAlreadyExist{ connection: Connection },
23
24 #[error("A Loop is created with the connection = {connection:?}")]
25 LoopCreated { connection: Connection },
26
27 #[error("Component with id = {component:?} not have a Input = {in_port:?}")]
28 InPortNotFound { component: Id, in_port: PortId },
29
30 #[error("Component with id = {component:?} not have a Output = {out_port:?}")]
31 OutPortNotFound { component: Id, out_port: PortId },
32
33 #[error("A queue of componenet id = {component:?} and port = {port:?} has not created, verify if a connection with this port exist")]
34 QueueNotCreated { component: Id, port: PortId },
35
36 #[error("No packages were consumed from the component = {component:?}")]
37 AnyPackageConsumed { component: Id },
38
39 #[error("The global data could not be accessed")]
40 CannotAccessGlobal,
41}