Skip to main content

acta_maker_sdk/ws/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4#[non_exhaustive]
5pub enum WsClientError {
6    #[error("websocket error: {0}")]
7    WebSocket(#[from] tokio_tungstenite::tungstenite::Error),
8    #[error("json error: {0}")]
9    Json(#[from] serde_json::Error),
10    #[error("read timeout")]
11    Timeout,
12    #[error("websocket connect timed out")]
13    ConnectTimeout,
14    #[error("connection closed")]
15    ConnectionClosed,
16    #[error("protocol error: {0}")]
17    Protocol(String),
18    #[error(transparent)]
19    InvalidTransportConfig(#[from] WsTransportConfigError),
20}
21
22#[derive(Debug, Error, Clone, Copy, PartialEq, Eq)]
23#[non_exhaustive]
24pub enum WsTransportConfigError {
25    #[error("connect timeout must be non-zero")]
26    ZeroConnectTimeout,
27    #[error("websocket message and frame limits must be non-zero")]
28    ZeroMessageOrFrameLimit,
29    #[error("maximum write buffer size must exceed write buffer size")]
30    InvalidWriteBufferRange,
31}
32
33pub type WsResult<T> = Result<T, WsClientError>;