Skip to main content

synapse_pingora/horizon/
error.rs

1//! Error types for Signal Horizon integration.
2
3use thiserror::Error;
4
5/// Errors from the Horizon client.
6#[derive(Debug, Error)]
7pub enum HorizonError {
8    /// Configuration error
9    #[error("Configuration error: {0}")]
10    ConfigError(String),
11
12    /// Connection failed
13    #[error("Connection failed: {0}")]
14    ConnectionFailed(String),
15
16    /// Authentication failed
17    #[error("Authentication failed: {0}")]
18    AuthFailed(String),
19
20    /// Send failed
21    #[error("Send failed: {0}")]
22    SendFailed(String),
23
24    /// WebSocket error
25    #[error("WebSocket error: {0}")]
26    WebSocket(String),
27
28    /// Serialization error
29    #[error("Serialization error: {0}")]
30    Serialization(String),
31
32    /// Deserialization error
33    #[error("Deserialization error: {0}")]
34    Deserialization(String),
35
36    /// Timeout
37    #[error("Timeout: {0}")]
38    Timeout(String),
39
40    /// Not connected
41    #[error("Not connected")]
42    NotConnected,
43
44    /// Already connected
45    #[error("Already connected")]
46    AlreadyConnected,
47}
48
49impl From<serde_json::Error> for HorizonError {
50    fn from(e: serde_json::Error) -> Self {
51        HorizonError::Serialization(e.to_string())
52    }
53}
54
55impl From<tokio_tungstenite::tungstenite::Error> for HorizonError {
56    fn from(e: tokio_tungstenite::tungstenite::Error) -> Self {
57        HorizonError::WebSocket(e.to_string())
58    }
59}