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("Connection closed: {reason}")]
20    ConnectionClosed { reason: String },
21
22    #[error("Server error {code}: {message}")]
23    ServerError { code: u32, message: String },
24
25    #[error("WebSocket error: {0}")]
26    WebSocket(#[from] tokio_tungstenite::tungstenite::Error),
27
28    #[error("Serialization error: {0}")]
29    Serialization(#[from] rmp_serde::encode::Error),
30
31    #[error("Deserialization error: {0}")]
32    Deserialization(#[from] rmp_serde::decode::Error),
33
34    #[error("Operation timed out after {duration_ms}ms")]
35    Timeout { duration_ms: u64 },
36
37    #[error(transparent)]
38    Unexpected(#[from] anyhow::Error),
39}