1use tungstenite::http;
4
5use crate::message::Message;
6
7type TungsteniteError = Box<tungstenite::Error>;
8
9#[derive(Debug, thiserror::Error)]
11pub enum Error {
12 #[error("couldn't add the vsn header to uri")]
14 Uri(#[source] http::uri::InvalidUri),
15 #[error("couldn't build the uri with the vsn version")]
17 UriBuild(#[source] http::Error),
18 #[error("couldn't connect to the web-socket")]
20 Connect(#[source] TungsteniteError),
21 #[error("couldn't serialize message")]
23 Serialize(#[source] serde_json::Error),
24 #[error("couldn't deserialize message")]
26 Deserialize(#[source] serde_json::Error),
27 #[error("couldn't send message {msg}")]
29 Send {
30 msg: Message<()>,
32 #[source]
33 backtrace: TungsteniteError,
35 },
36 #[error("couldn't receive the message")]
38 Recv(#[source] TungsteniteError),
39 #[error("couldn't decode websocket message, not of type text")]
41 WebSocketMessageType(#[source] TungsteniteError),
42 #[error("the web-socket disconnected")]
44 Disconnected,
45}