1use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, RouterError>;
6
7#[cfg(feature = "mqtt-server")]
8impl From<mqttbytes::Error> for RouterError {
9 fn from(e: mqttbytes::Error) -> Self {
10 RouterError::Mqtt(e)
11 }
12}
13
14#[derive(Error, Debug)]
15pub enum RouterError {
16 #[error("session not found: {0}")]
17 SessionNotFound(String),
18
19 #[error("invalid message: {0}")]
20 InvalidMessage(String),
21
22 #[error("routing error: {0}")]
23 Routing(String),
24
25 #[error("state error: {0}")]
26 State(String),
27
28 #[error("configuration error: {0}")]
29 Config(String),
30
31 #[error("transport error: {0}")]
32 Transport(#[from] clasp_transport::TransportError),
33
34 #[error("core protocol error: {0}")]
35 Core(#[from] clasp_core::Error),
36
37 #[error("protocol error: {0}")]
38 Protocol(String),
39
40 #[error("authentication error: {0}")]
41 Auth(String),
42
43 #[error("I/O error: {0}")]
44 Io(#[from] std::io::Error),
45
46 #[error("router error: {0}")]
47 Other(String),
48
49 #[cfg(feature = "mqtt-server")]
50 #[error("MQTT protocol error: {0:?}")]
51 Mqtt(mqttbytes::Error),
52}