reactive_graph_graph/instances/entities/
entity_instance_errors.rs1use crate::EntityTypeId;
2use crate::InvalidComponentError;
3use crate::NamespacedTypeParseError;
4use thiserror::Error;
5use uuid::Uuid;
6
7#[derive(Debug, Error)]
8pub enum QueryEntityInstanceError {
9 #[error("The given uuid is invalid")]
10 InvalidUuid(#[from] uuid::Error),
11 #[error("The entity instance {0} does not exist")]
12 EntityInstanceDoesNotExist(Uuid),
13 #[error("No entity instance with label {0} exists")]
14 EntityInstanceWithLabelDoesNotExist(String),
15 #[error("The entity instance {0} is not of type {1}")]
16 EntityInstanceIsNotOfType(Uuid, EntityTypeId),
17}
18
19#[derive(Debug, Error)]
20pub enum CreateEntityInstanceError {
21 #[error("Cannot create entity instance of non-existing type {0}")]
22 EntityTypeDoesNotExist(EntityTypeId),
23 #[error("Cannot create entity instance because id {0} already exists")]
24 EntityInstanceAlreadyExist(Uuid),
25 #[error("Cannot create entity instance because one or multiple components does not exist")]
26 ComponentsDoesNotExist,
27}
28
29#[derive(Debug, Error)]
30pub enum AddEntityInstanceError {
31 #[error("The entity instance {0} already exists")]
32 EntityInstanceAlreadyExist(Uuid),
33}
34
35#[derive(Debug, Error)]
36pub enum UpdateEntityInstanceError {
37 #[error("The entity instance {0} does not exist")]
38 EntityInstanceDoesNotExist(Uuid),
39 #[error("No entity instance with label {0} exists")]
40 EntityInstanceWithLabelDoesNotExist(String),
41 #[error("Either the UUID or the label of the entity instance must be given")]
42 EitherUuidOrLabelMustBeGiven,
43}
44
45#[derive(Debug, Error)]
46pub enum TriggerEntityInstanceError {
47 #[error("Unable to trigger entity instance {0} because there is no property trigger")]
48 TriggerPropertyMissing(Uuid),
49}
50
51#[derive(Debug, Error)]
52pub enum SubscribeEntityInstanceError {
53 #[error("The entity instance {0} does not exist")]
54 EntityInstanceDoesNotExist(Uuid),
55 #[error("No entity instance with label {0} exists")]
56 EntityInstanceWithLabelDoesNotExist(String),
57 #[error("Either the UUID or the label of the entity instance must be given")]
58 EitherUuidOrLabelMustBeGiven,
59 #[error("Unable to subscribe non-existing property {1} of entity instance {0}")]
60 PropertyNotFound(Uuid, String),
61}
62
63#[derive(Debug, Error)]
70pub enum RemoveEntityInstanceError {
71 #[error("The entity instance {0} does not exist")]
72 EntityInstanceDoesNotExist(Uuid),
73 #[error("The entity instance {0} is in use")]
74 EntityInstanceInUse(Uuid),
75}
76
77#[derive(Debug, Error)]
78pub enum InvalidEntityInstanceError {
79 #[error("The entity type is invalid: {0}")]
80 InvalidEntityType(#[from] NamespacedTypeParseError),
81 #[error("The component of the entity instance is invalid: {0}")]
82 InvalidComponent(#[from] InvalidComponentError),
83 #[error("Entity instance is of non-existing type {0}")]
84 EntityTypeDoesNotExist(EntityTypeId),
85}