use tungstenite::http;
use crate::message::Message;
type TungsteniteError = Box<tungstenite::Error>;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("couldn't add the vsn header to uri")]
Uri(#[source] http::uri::InvalidUri),
#[error("couldn't build the uri with the vsn version")]
UriBuild(#[source] http::Error),
#[error("couldn't connect to the web-socket")]
Connect(#[source] TungsteniteError),
#[error("couldn't serialize message")]
Serialize(#[source] serde_json::Error),
#[error("couldn't deserialize message")]
Deserialize(#[source] serde_json::Error),
#[error("couldn't send message {msg}")]
Send {
msg: Message<()>,
#[source]
backtrace: TungsteniteError,
},
#[error("couldn't receive the message")]
Recv(#[source] TungsteniteError),
#[error("couldn't decode websocket message, not of type text")]
WebSocketMessageType(#[source] TungsteniteError),
#[error("the web-socket disconnected")]
Disconnected,
}