reactive_graph_reactive_service_api/error/
flow.rs1use reactive_graph_graph::EntityTypeId;
2use reactive_graph_graph::FlowTypeId;
3use reactive_graph_graph::RelationTypeId;
4use reactive_graph_graph::TypeDefinitionGetter;
5use reactive_graph_reactive_model_api::ReactiveFlowConstructionError;
6use std::fmt;
7use uuid::Uuid;
8
9#[derive(Debug)]
11pub enum ReactiveFlowCreationError {
12 UuidTaken(Uuid),
13 MissingWrapperInstance,
14 ReactiveFlowConstructionError(ReactiveFlowConstructionError),
17 MissingVariable(String),
18 FlowTypeDoesntExist(FlowTypeId),
19 EntityTypeDoesntExist(EntityTypeId),
20 RelationTypeDoesntExist(RelationTypeId),
21 InvalidOutboundId(Uuid),
22 InvalidInboundId(Uuid),
23}
24
25impl fmt::Display for ReactiveFlowCreationError {
26 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27 match &self {
28 ReactiveFlowCreationError::UuidTaken(id) => {
29 write!(f, "The UUID {id} has been already taken!")
30 }
31 ReactiveFlowCreationError::MissingWrapperInstance => {
32 write!(f, "The created wrapper instance cannot be found")
33 }
34 ReactiveFlowCreationError::ReactiveFlowConstructionError(e) => write!(f, "Failed to construct reactive flow: {e}"),
37 ReactiveFlowCreationError::MissingVariable(variable_name) => {
38 write!(
39 f,
40 "Failed to construct reactive flow instance: Flow type requires variable {variable_name} which wasn't provided"
41 )
42 }
43 ReactiveFlowCreationError::FlowTypeDoesntExist(flow_ty) => {
44 write!(f, "Failed to construct reactive flow instance: Flow type {} doesn't exist", flow_ty.type_definition())
45 }
46 ReactiveFlowCreationError::EntityTypeDoesntExist(entity_ty) => {
47 write!(
48 f,
49 "Failed to construct reactive flow instance: Flow type contains an entity instance of type {} which doesn't exist",
50 entity_ty.type_definition()
51 )
52 }
53 ReactiveFlowCreationError::RelationTypeDoesntExist(relation_ty) => {
54 write!(
55 f,
56 "Failed to construct reactive flow instance: Flow type contains a relation instance of type {} which doesn't exist",
57 relation_ty.type_definition()
58 )
59 }
60 ReactiveFlowCreationError::InvalidOutboundId(id) => {
61 write!(
62 f,
63 "Failed to construct reactive flow instance: Flow type provides relation instance which outbound refers to a entity instance with id {id} which doesn't exist"
64 )
65 }
66 ReactiveFlowCreationError::InvalidInboundId(id) => {
67 write!(
68 f,
69 "Failed to construct reactive flow instance: Flow type provides relation instance which inbound refers to entity instance with id {id} which doesn't exist",
70 )
71 }
72 }
73 }
74}
75
76impl From<ReactiveFlowCreationError> for String {
77 fn from(e: ReactiveFlowCreationError) -> Self {
78 format!("{e}")
79 }
80}
81
82#[derive(Debug)]
83pub struct ReactiveFlowImportError;