mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 19:47:59 +00:00
rpc-api: use thiserror instead of derive_more for error handling (#9631)
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
This commit is contained in:
@@ -24,22 +24,14 @@ use jsonrpc_core as rpc;
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
/// Offchain RPC errors.
|
||||
#[derive(Debug, derive_more::Display, derive_more::From)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum Error {
|
||||
/// Unavailable storage kind error.
|
||||
#[display(fmt = "This storage kind is not available yet.")]
|
||||
#[error("This storage kind is not available yet.")]
|
||||
UnavailableStorageKind,
|
||||
/// Call to an unsafe RPC was denied.
|
||||
UnsafeRpcCalled(crate::policy::UnsafeRpcError),
|
||||
}
|
||||
|
||||
impl std::error::Error for Error {
|
||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||
match self {
|
||||
Self::UnsafeRpcCalled(err) => Some(err),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
#[error(transparent)]
|
||||
UnsafeRpcCalled(#[from] crate::policy::UnsafeRpcError),
|
||||
}
|
||||
|
||||
/// Base error code for all offchain errors.
|
||||
|
||||
Reference in New Issue
Block a user