event_notification/
error.rs1use thiserror::Error;
2use tokio::sync::mpsc::error;
3use tokio::task::JoinError;
4
5#[derive(Error, Debug)]
8pub enum Error {
9 #[error("Join error: {0}")]
10 JoinError(#[from] JoinError),
11 #[error("IO error: {0}")]
12 Io(#[from] std::io::Error),
13 #[error("Serialization error: {0}")]
14 Serde(#[from] serde_json::Error),
15 #[error("HTTP error: {0}")]
16 Http(#[from] reqwest::Error),
17 #[cfg(feature = "kafka")]
18 #[error("Kafka error: {0}")]
19 Kafka(#[from] rdkafka::error::KafkaError),
20 #[cfg(feature = "mqtt")]
21 #[error("MQTT error: {0}")]
22 Mqtt(#[from] rumqttc::ClientError),
23 #[error("Channel send error: {0}")]
24 ChannelSend(#[from] Box<error::SendError<crate::event::Event>>),
25 #[error("Feature disabled: {0}")]
26 FeatureDisabled(&'static str),
27 #[error("Event bus already started")]
28 EventBusStarted,
29 #[error("necessary fields are missing:{0}")]
30 MissingField(&'static str),
31 #[error("field verification failed:{0}")]
32 ValidationError(&'static str),
33 #[error("{0}")]
34 Custom(String),
35 #[error("Configuration error: {0}")]
36 ConfigError(String),
37 #[error("Configuration loading error: {0}")]
38 Figment(#[from] figment::Error),
39}
40
41impl Error {
42 pub(crate) fn custom(msg: &str) -> Error {
43 Self::Custom(msg.to_string())
44 }
45}