Skip to main content

titan_rust_client/
error.rs

1//! Error types for the Titan client.
2
3use thiserror::Error;
4
5#[derive(Debug, Error)]
6pub enum TitanClientError {
7    #[error("Authentication failed: {0}")]
8    AuthenticationFailed(String),
9
10    #[error("Rate limited: retry after {retry_after_ms}ms")]
11    RateLimited { retry_after_ms: u64 },
12
13    #[error("Stream limit exceeded")]
14    StreamLimitExceeded,
15
16    #[error("Connection failed after {attempts} attempts: {reason}")]
17    ConnectionFailed { attempts: u32, reason: String },
18
19    #[error("Server error {code}: {message}")]
20    ServerError { code: u32, message: String },
21
22    #[error("WebSocket error: {0}")]
23    WebSocket(#[from] tokio_tungstenite::tungstenite::Error),
24
25    #[error("Serialization error: {0}")]
26    Serialization(#[from] rmp_serde::encode::Error),
27
28    #[error("Deserialization error: {0}")]
29    Deserialization(#[from] rmp_serde::decode::Error),
30
31    #[error(transparent)]
32    Unexpected(#[from] anyhow::Error),
33}