rust_rabbit/
error.rs

1use thiserror::Error;
2
3/// Main error type for the rust-rabbit library
4#[derive(Error, Debug)]
5pub enum RabbitError {
6    #[error("Connection error: {0}")]
7    Connection(#[from] lapin::Error),
8
9    #[error("Serialization error: {0}")]
10    Serialization(#[from] serde_json::Error),
11
12    #[error("Serialization error: {0}")]
13    SerializationError(String),
14
15    #[error("Configuration error: {0}")]
16    Configuration(String),
17
18    #[error("Channel error: {0}")]
19    ChannelError(String),
20
21    #[error("Consumer error: {0}")]
22    Consumer(String),
23
24    #[error("Publisher error: {0}")]
25    Publisher(String),
26
27    #[error("Retry exhausted: {0}")]
28    RetryExhausted(String),
29
30    #[error("Health check failed: {0}")]
31    HealthCheck(String),
32
33    #[error("Timeout error: {0}")]
34    Timeout(String),
35
36    #[error("IO error: {0}")]
37    Io(#[from] std::io::Error),
38
39    #[error("Generic error: {0}")]
40    Generic(#[from] anyhow::Error),
41}
42
43/// Result type alias for the rust-rabbit library
44pub type Result<T> = std::result::Result<T, RabbitError>;