Skip to main content

basilisk_rust_client/
error.rs

1use thiserror::Error;
2
3/// Standard result type used by service-bus client operations.
4pub type ClientResult<T> = Result<T, ClientError>;
5
6/// Error type returned by low-level bus operations.
7#[derive(Debug, Error)]
8pub enum ClientError {
9    /// I/O failure while reading from or writing to the TCP socket.
10    #[error("I/O error: {0}")]
11    Io(#[from] std::io::Error),
12    /// JSON serialization or deserialization failure for protocol frames.
13    #[error("JSON serialization error: {0}")]
14    Serde(#[from] serde_json::Error),
15    /// Protocol-level error frame returned by the service bus.
16    #[error("protocol error {code}: {message}")]
17    Protocol { code: String, message: String },
18    /// A required field was missing from a received frame.
19    #[error("protocol message missing expected field: {0}")]
20    MissingField(&'static str),
21    /// Internal request/response channel closed unexpectedly.
22    #[error("background channel closed")]
23    ChannelClosed,
24    /// Received a frame type that does not match the expected response.
25    #[error("unexpected protocol message type: {0}")]
26    UnexpectedMessage(String),
27}