reactive_graph_behaviour_model_api/
error.rs

1use thiserror::Error;
2
3use crate::BehaviourTypeId;
4use reactive_graph_graph::DataType;
5
6#[derive(Debug, Error)]
7pub enum BehaviourTransitionError {
8    #[error("Invalid transition")]
9    InvalidTransition,
10    #[error("The behaviour is invalid: {0}")]
11    BehaviourInvalid(#[from] BehaviourInvalid),
12    #[error("Failed to initialize the behaviour: {0}")]
13    BehaviourInitializationFailed(#[from] BehaviourInitializationFailed),
14    #[error("Connect the behaviour failed: {0}")]
15    BehaviourConnectFailed(#[from] BehaviourConnectFailed),
16    #[error("Disconnect the behaviour failed: {0}")]
17    BehaviourDisconnectFailed(#[from] BehaviourDisconnectFailed),
18}
19
20#[derive(Debug, Error)]
21pub enum BehaviourCreationError {
22    #[error("Creating the behaviour {0} failed because the behaviour is already applied on the reactive instance!")]
23    BehaviourAlreadyApplied(BehaviourTypeId),
24    /// Creating the behaviour failed because connecting the behaviour failed.
25    #[error("Creating the behaviour failed: {0}")]
26    BehaviourTransitionError(#[from] BehaviourTransitionError),
27}
28
29#[derive(Debug, Error)]
30#[error("Connect the behaviour failed")]
31pub struct BehaviourConnectFailed {
32    // TODO: more detailed reasons
33}
34
35#[derive(Debug, Error)]
36#[error("Disconnect the behaviour failed")]
37pub struct BehaviourDisconnectFailed {
38    // TODO: more detailed reasons
39}
40
41#[derive(Debug, Error)]
42pub enum BehaviourReconnectFailed {
43    #[error("Reconnect failed because: Connect the behaviour failed: {0}")]
44    BehaviourConnectFailed(#[from] BehaviourConnectFailed),
45    #[error("Reconnect failed because: Disconnect the behaviour failed: {0}")]
46    BehaviourDisconnectFailed(#[from] BehaviourDisconnectFailed),
47}
48
49#[derive(Debug, Error)]
50#[error("Failed to initialize the behaviour!")]
51pub struct BehaviourInitializationFailed {
52    // TODO: more detailed reasons
53}
54
55#[derive(Debug, Error)]
56#[error("Failed to shut down the behaviour!")]
57pub struct BehaviourShutdownFailed {
58    // TODO: more detailed reasons
59}
60
61#[derive(Debug, Error)]
62pub enum BehaviourInvalid {
63    #[error("The behaviour is invalid because one or multiple properties are invalid: {0}")]
64    BehaviourPropertyInvalid(#[from] BehaviourPropertyInvalid),
65}
66
67#[derive(Debug, Error)]
68pub enum BehaviourPropertyInvalid {
69    #[error("Missing property {0}")]
70    PropertyMissing(String),
71
72    #[error("Missing outbound property {0}")]
73    OutboundPropertyMissing(String),
74
75    #[error("Missing inbound property {0}")]
76    InboundPropertyMissing(String),
77
78    /// The property with the given name has a data type which is not the expected data type.
79    #[error("Property {0} has data type {1} but data type {2} was expected!")]
80    InvalidDataType(String, DataType, DataType),
81}
82
83#[derive(Debug, Error)]
84#[error("Failed to apply the behaviour")]
85pub struct BehaviourFunctionError;