lightclient: Add light client Error

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
Alexandru Vasile
2023-05-18 20:03:11 +03:00
parent 68e239a33a
commit e54aa6a569
2 changed files with 39 additions and 0 deletions
+7
View File
@@ -8,6 +8,9 @@ mod dispatch_error;
use core::fmt::Debug;
#[cfg(feature = "experimental-light-client")]
pub use crate::rpc::LightClientError;
// Re-export dispatch error types:
pub use dispatch_error::{
ArithmeticError, DispatchError, ModuleError, RawModuleError, TokenError, TransactionalError,
@@ -63,6 +66,10 @@ pub enum Error {
/// The bytes representing an error that we were unable to decode.
#[error("An error occurred but it could not be decoded: {0:?}")]
Unknown(Vec<u8>),
/// Light client error.
#[cfg(feature = "experimental-light-client")]
#[error("An error occurred but it could not be decoded: {0:?}")]
LightClient(#[from] LightClientError),
/// Other error.
#[error("Other error: {0}")]
Other(String),
+32
View File
@@ -0,0 +1,32 @@
mod background;
mod client;
pub use client::LightClient;
/// Light client error.
#[derive(Debug, thiserror::Error)]
pub enum LightClientError {
/// Error encountered while adding the chain to the light-client.
#[error("Failed to add the chain to the light client: {0}")]
AddChainError(String),
/// The background task is closed.
#[error("Failed to communicate with the background task.")]
BackgroundClosed,
/// Invalid RPC parameters cannot be serialized as JSON string.
#[error("RPC parameters cannot be serialized as JSON string.")]
InvalidParams,
/// Error originated while trying to submit a RPC request.
#[error("RPC request cannot be sent: {0}")]
Request(String),
/// The provided URL scheme is invalid.
///
/// Supported versions: WS, WSS.
#[error("The provided URL scheme is invalid.")]
InvalidScheme,
/// The provided URL is invalid.
#[error("The provided URL scheme is invalid.")]
InvalidUrl,
/// Handshake error while connecting to a node.
#[error("WS handshake failed")]
Handshake,
}