use {thiserror::Error, tokio_native_tls::native_tls};
#[derive(Error, Debug)]
pub enum RpcClientError {
#[error("marshaller error: {0}")]
Marshaller(serde_json::Error),
#[error("unregistered notification callback, type: {0}")]
UnregisteredNotification(String),
#[error("rpc authentication error")]
RpcAuthenticationRequest,
#[error("tcp stream error: {0}")]
TcpStream(std::io::Error),
#[error("websocket tls certificate error: {0}")]
WsTlsCertificate(native_tls::Error),
#[error("tls handshake error: {0}")]
TlsHandshake(native_tls::Error),
#[error("tls stream error: {0}")]
TlsStream(native_tls::Error),
#[error("rpc handshake error: {0}")]
RpcHandshake(tokio_tungstenite::tungstenite::Error),
#[error("invalid proxy connection")]
ProxyConnection,
#[error("proxy authentication request error: {0}")]
ProxyAuthentication(std::io::Error),
#[error("rpc proxy http status error: {0:?}")]
RpcProxyStatus(Option<u16>),
#[error("rpc proxied reponse error: {0}")]
RpcProxyResponseParse(httparse::Error),
#[error("rpc client disconnected")]
RpcDisconnected,
#[error("websocket already connected to RPC server")]
WebsocketAlreadyConnected,
#[error("HTTP certificate error: {0}")]
HttpTlsCertificate(reqwest::Error),
#[error("failed to set HTTP header on HTTP Post mode, error: {0}")]
HttpHeader(reqwest::header::InvalidHeaderValue),
#[error("error initiating HTTP Hanshake in HTTP Post mode, error: {0}")]
HttpHandshake(reqwest::Error),
}