Skip to main content

topiq_core/
error.rs

1use thiserror::Error;
2
3/// Errors that can occur in the topiq system.
4#[derive(Debug, Error)]
5pub enum TopiqError {
6    #[error("invalid subject: {reason}")]
7    InvalidSubject { reason: String },
8
9    #[error("protocol error: {0}")]
10    Protocol(String),
11
12    #[error("unsupported protocol version: {version}")]
13    UnsupportedVersion { version: u8 },
14
15    #[error("frame too large: {size} bytes (max {max})")]
16    FrameTooLarge { size: usize, max: usize },
17
18    #[error("transport error: {0}")]
19    Transport(#[from] std::io::Error),
20
21    #[error("codec error: {0}")]
22    Codec(String),
23
24    #[error("connection closed")]
25    ConnectionClosed,
26
27    #[error("request timed out")]
28    Timeout,
29
30    #[error("buffer full for subscription {sid}")]
31    Backpressure { sid: u64 },
32}
33
34pub type Result<T> = std::result::Result<T, TopiqError>;