mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-05 02:47:25 +00:00
connect to substrate using ws (#417)
This commit is contained in:
committed by
Bastian Köcher
parent
ede0ff8656
commit
55d22a0d1e
@@ -17,6 +17,7 @@
|
||||
//! Substrate node RPC errors.
|
||||
|
||||
use jsonrpsee::client::RequestError;
|
||||
use jsonrpsee::transport::ws::WsNewDnsError;
|
||||
use relay_utils::MaybeConnectionError;
|
||||
|
||||
/// Result type used by Substrate client.
|
||||
@@ -26,13 +27,21 @@ pub type Result<T> = std::result::Result<T, Error>;
|
||||
/// a Substrate node through RPC.
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
/// Web socket connection error.
|
||||
WsConnectionError(WsNewDnsError),
|
||||
/// An error that can occur when making an HTTP request to
|
||||
/// an JSON-RPC client.
|
||||
/// an JSON-RPC server.
|
||||
Request(RequestError),
|
||||
/// The response from the client could not be SCALE decoded.
|
||||
/// The response from the server could not be SCALE decoded.
|
||||
ResponseParseFailed(codec::Error),
|
||||
}
|
||||
|
||||
impl From<WsNewDnsError> for Error {
|
||||
fn from(error: WsNewDnsError) -> Self {
|
||||
Error::WsConnectionError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RequestError> for Error {
|
||||
fn from(error: RequestError) -> Self {
|
||||
Error::Request(error)
|
||||
@@ -54,6 +63,7 @@ impl From<Error> for String {
|
||||
impl ToString for Error {
|
||||
fn to_string(&self) -> String {
|
||||
match self {
|
||||
Self::WsConnectionError(e) => e.to_string(),
|
||||
Self::Request(e) => e.to_string(),
|
||||
Self::ResponseParseFailed(e) => e.what().to_string(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user