reactive_graph_graph/instances/relations/
relation_instance_errors.rs1use crate::InstanceIdError;
2use crate::InvalidComponentError;
3use crate::NamespacedTypeParseError;
4use crate::RelationInstanceId;
5use crate::RelationTypeId;
6use crate::TypeDefinitionParseError;
7use crate::TypeIdParseError;
8use thiserror::Error;
9use uuid::Uuid;
10
11#[derive(Debug, Error)]
12pub enum CreateRelationInstanceError {
13 #[error("Cannot create relation instance of non-existing type {0}")]
14 RelationTypeDoesNotExist(RelationTypeId),
15 #[error("Cannot create relation instance of type {0} because outbound entity instance {1} does not exist")]
16 OutboundEntityInstanceDoesNotExist(RelationTypeId, Uuid),
17 #[error("Cannot create relation instance of type {0} because inbound entity instance {1} does not exist")]
18 InboundEntityInstanceDoesNotExist(RelationTypeId, Uuid),
19 #[error("Cannot create relation instance because one or multiple components does not exist")]
20 ComponentsDoesNotExist,
21}
22#[derive(Debug, Error)]
23pub enum CreatePropertyConnectorError {
24 #[error("Cannot create connector because {0}")]
25 CreateRelationInstanceError(#[from] CreateRelationInstanceError),
26 #[error("Cannot create connector of type {0} because outbound entity instance {1} has no property {2}")]
27 OutboundPropertyDoesNotExist(RelationTypeId, Uuid, String),
28 #[error("Cannot create connector of type {0} because inbound entity instance {1} has no property {2}")]
29 InboundPropertyDoesNotExist(RelationTypeId, Uuid, String),
30}
31
32#[derive(Debug, Error)]
33pub enum AddRelationInstanceError {
34 #[error("The relation instance {0} already exists")]
35 RelationInstanceAlreadyExist(RelationInstanceId),
36 #[error("The outbound entity instance {0} does not exist")]
37 OutboundEntityInstanceDoesNotExist(Uuid),
38 #[error("The inbound entity instance {0} does not exist")]
39 InboundEntityInstanceDoesNotExist(Uuid),
40}
41
42#[derive(Debug, Error)]
43pub enum UpdateRelationInstanceError {
44 #[error("Cannot create relation instance of non-existing type {0}")]
45 RelationTypeDoesNotExist(RelationTypeId),
46 #[error("The outbound entity instance {0} does not exist")]
47 OutboundEntityInstanceDoesNotExist(Uuid),
48 #[error("The inbound entity instance {0} does not exist")]
49 InboundEntityInstanceDoesNotExist(Uuid),
50 #[error("The relation instance {0} does not exist")]
51 RelationInstanceDoesNotExist(RelationInstanceId),
52}
53
54#[derive(Debug, Error)]
55pub enum TriggerRelationInstanceError {
56 #[error("The relation instance {0} does not exist")]
57 RelationInstanceDoesNotExist(RelationInstanceId),
58 #[error("Unable to trigger relation instance {0} because there is no property trigger")]
59 TriggerPropertyMissing(RelationInstanceId),
60}
61
62#[derive(Debug, Error)]
63pub enum SubscribeRelationInstanceError {
64 #[error("The relation instance {0} does not exist")]
65 RelationInstanceDoesNotExist(RelationInstanceId),
66 #[error("Unable to subscribe non-existing property {1} of relation instance {0}")]
67 PropertyNotFound(RelationInstanceId, String),
68}
69
70#[derive(Debug, Error)]
71pub enum RemoveRelationInstanceError {
72 #[error("The relation instance {0} is in use")]
73 RelationInstanceDoesNotExist(RelationInstanceId),
74 #[error("The outbound entity instance {0} does not exist")]
75 OutboundEntityInstanceDoesNotExist(Uuid),
76 #[error("The inbound entity instance {0} does not exist")]
77 InboundEntityInstanceDoesNotExist(Uuid),
78}
79
80#[derive(Debug, Error)]
81pub enum RelationInstanceTypeIdParseError {
82 #[error("Failed to parse namespace: {0}")]
83 NamespacedTypeParseError(#[from] NamespacedTypeParseError),
84 #[error("Failed to parse instance id: {0}")]
85 InstanceIdError(#[from] InstanceIdError),
86 #[error("Failed to parse type definition: {0}")]
87 TypeDefinitionParseError(#[from] TypeDefinitionParseError),
88 #[error("Failed to parse type id: {0}")]
89 TypeIdParseError(#[from] TypeIdParseError),
90}
91
92#[derive(Debug, Error)]
93pub enum RelationInstanceTypeIdError {
94 #[error("Failed to construct relation instance type id because of an error with the instance id: {0}")]
95 InstanceIdError(#[from] InstanceIdError),
96 #[error("Failed to construct relation instance type id because of an error with the namespaced type: {0}")]
97 NamespacedTypeParseError(#[from] NamespacedTypeParseError),
98}
99
100#[derive(Debug, Error)]
101pub enum RelationInstanceIdParseError {
102 #[error("The outbound id is missing")]
103 MissingOutboundId,
104 #[error("The outbound id {0} is invalid")]
105 InvalidOutboundId(String),
106 #[error("Failed to parse relation instance type id: {0}")]
107 RelationInstanceTypeIdParseError(#[from] RelationInstanceTypeIdParseError),
108 #[error("The inbound id is missing")]
109 MissingInboundId,
110 #[error("The inbound id {0} is invalid")]
111 InvalidInboundId(String),
112}
113
114#[derive(Debug, Error)]
115pub enum InvalidRelationInstanceError {
116 #[error("The relation instance type id is invalid: {0}")]
117 InvalidRelationInstanceTypeId(#[from] RelationInstanceTypeIdError),
118 #[error("The component of the relation instance is invalid: {0}")]
119 InvalidComponent(#[from] InvalidComponentError),
120 #[error("The relation instance is of non-existing type {0}")]
121 RelationTypeDoesNotExist(RelationTypeId),
122}