reactive_graph_reactive_service_api/error/
relation.rs1use thiserror::Error;
2use uuid::Uuid;
3
4use reactive_graph_graph::ComponentTypeId;
5use reactive_graph_graph::EntityTypeId;
6use reactive_graph_graph::RelationInstanceId;
7use reactive_graph_graph::RelationTypeId;
8
9#[derive(Debug, Error)]
10pub enum ReactiveRelationCreationError {
11 #[error("The outbound entity {0} doesn't have component {1}!")]
12 OutboundEntityDoesNotHaveComponent(Uuid, ComponentTypeId),
13 #[error("The outbound entity {0} is of type {1} but expected {2}!")]
14 OutboundEntityIsNotOfType(Uuid, EntityTypeId, EntityTypeId),
15 #[error("The inbound entity {0} doesn't have component {1}!")]
16 InboundEntityDoesNotHaveComponent(Uuid, ComponentTypeId),
17 #[error("The inbound entity {0} is of type {1} but expected {2}!")]
18 InboundEntityIsNotOfType(Uuid, EntityTypeId, EntityTypeId),
19 #[error("The outbound entity {0} doesn't exist!")]
20 MissingOutboundEntityInstance(Uuid),
21 #[error("The inbound entity {0} doesn't exist!")]
22 MissingInboundEntityInstance(Uuid),
23 #[error("The created reactive relation {0} wasn't found after creation!")]
24 MissingInstance(RelationInstanceId),
25 #[error("The relation type {0} is unknown!")]
26 UnknownRelationType(RelationTypeId),
27 #[error("Failed to register the reactive relation: {0}")]
29 ReactiveRelationRegistrationError(ReactiveRelationRegistrationError),
30}
31
32#[derive(Debug, Error)]
33pub enum ReactiveRelationRegistrationError {
34 #[error("Couldn't register reactive relation {0} because it already exists!")]
35 RelationInstanceAlreadyExists(RelationInstanceId),
36}
37
38#[derive(Debug, Error)]
39pub enum ReactiveRelationComponentAddError {
40 #[error("The reactive relation {0} wasn't found!")]
41 MissingInstance(RelationInstanceId),
42 #[error("Couldn't add the unknown component {0} to the reactive relation!")]
43 ComponentNotRegistered(ComponentTypeId),
44 #[error("The reactive relation is already {0}!")]
45 IsAlreadyA(ComponentTypeId),
46}
47
48#[derive(Debug, Error)]
49pub enum ReactiveRelationComponentRemoveError {
50 #[error("The reactive relation {0} wasn't found!")]
51 MissingInstance(RelationInstanceId),
52 #[error("Couldn't remove the unknown component {0}!")]
53 ComponentNotRegistered(ComponentTypeId),
54 #[error("The reactive relation is not a {0}!")]
55 IsNotA(ComponentTypeId),
56}
57
58#[derive(Debug, Error)]
59pub enum ReactiveRelationPropertyAddError {
60 #[error("The reactive relation {0} wasn't found!")]
61 MissingInstance(RelationInstanceId),
62 #[error("The reactive relation already has property {0}!")]
63 PropertyAlreadyExists(String),
64}
65
66#[derive(Debug, Error)]
67pub enum ReactiveRelationPropertyRemoveError {
68 #[error("The reactive relation {0} wasn't found!")]
69 MissingInstance(RelationInstanceId),
70 #[error("The reactive relation doesn't has a property {0}!")]
71 MissingProperty(String),
72 #[error("Cannot remove property {0} because it is still in use!")]
73 PropertyInUseByComponent(ComponentTypeId),
74}