1use thiserror::Error;
9
10#[derive(Error, Debug)]
11pub enum MiddlewareError {
12 #[error("Unable to create Participant")]
13 DDSError(#[from] cyclonedds_rs::DDSError),
14 #[error("the data for key `{0}` is not available")]
15 Redaction(String),
16 #[error("invalid header (expected {expected:?}, found {found:?})")]
17 InvalidHeader {
18 expected: String,
19 found: String,
20 },
21 #[error("Data structures inconsistent (would have panicked)")]
22 InconsistentDataStructure,
23 #[error("Internal error")]
24 InternalError,
25 #[error("IO Error")]
26 IoError(#[from] std::io::Error),
27 #[error("Configuration Error - check config file")]
28 ConfigurationError,
29 #[error("Async reader error")]
30 ASyncReaderError(#[from] cyclonedds_rs::error::ReaderError),
31 #[error("Shared memory Not enabled")]
32 SharedMemoryNotEnabled,
33 #[error("Qos error")]
34 QosError,
35
36}
37
38
39#[derive(Error, Debug)]
40pub enum DDSError {
41 #[error("DDS Error")]
42 DdsError,
43 #[error("DDS Unsupported")]
44 Unsupported,
45 #[error("Bad Parameter")]
46 BadParameter,
47 #[error("Preconditions not met")]
48 PreconditionNotMet,
49 #[error("Out of Resources")]
50 OutOfResources,
51 #[error("Not Enabled")]
52 NotEnabled,
53 #[error("Immutable Policy")]
54 ImmutablePolicy,
55 #[error("Inconsistent Policy")]
56 InconsistentPolicy,
57 #[error("Already Deleted")]
58 AlreadyDeleted,
59 #[error("Timeout")]
60 Timeout,
61 #[error("No Data")]
62 NoData,
63 #[error("Illegal Operation")]
64 IllegalOperation,
65 #[error("Not allowed by security")]
66 NotAllowedBySecurity,
67}
68
69impl From<cyclonedds_rs::DDSError> for DDSError {
70 fn from(cdds_error: cyclonedds_rs::DDSError) -> Self {
71 match cdds_error {
72 cyclonedds_rs::DDSError::DdsOk => panic!("Don't expect a non-error"),
73 cyclonedds_rs::DDSError::DdsError => Self::DdsError,
74 cyclonedds_rs::DDSError::Unsupported => Self::Unsupported,
75 cyclonedds_rs::DDSError::BadParameter => Self::BadParameter,
76 cyclonedds_rs::DDSError::PreconditionNotMet => Self::PreconditionNotMet,
77 cyclonedds_rs::DDSError::OutOfResources => Self::OutOfResources,
78 cyclonedds_rs::DDSError::NotEnabled => Self::NotEnabled,
79 cyclonedds_rs::DDSError::ImmutablePolicy => Self::ImmutablePolicy,
80 cyclonedds_rs::DDSError::InconsistentPolicy => Self::InconsistentPolicy,
81 cyclonedds_rs::DDSError::AlreadyDeleted => Self::AlreadyDeleted,
82 cyclonedds_rs::DDSError::Timeout => Self::Timeout,
83 cyclonedds_rs::DDSError::NoData => Self::NoData,
84 cyclonedds_rs::DDSError::IllegalOperation => Self::IllegalOperation,
85 cyclonedds_rs::DDSError::NotAllowedBySecurity => Self::NotAllowedBySecurity,
86 }
87 }
88}