mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-11-01 16:31:07 +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:
1 parent
328cfbe633
commit
a636b7a512
8 files changed
+39
-74
No files matched your search
@@ -28,24 +28,16 @@ pub type Result<T> = std::result::Result<T, Error>;
|
||||
pub type FutureResult<T> = jsonrpc_core::BoxFuture<Result<T>>;
|
||||
|
||||
/// Chain RPC errors.
|
||||
#[derive(Debug, derive_more::Display, derive_more::From)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum Error {
|
||||
/// Client error.
|
||||
#[display(fmt = "Client error: {}", _0)]
|
||||
Client(Box<dyn std::error::Error + Send>),
|
||||
#[error("Client error: {}", .0)]
|
||||
Client(#[from] Box<dyn std::error::Error + Send>),
|
||||
/// Other error type.
|
||||
#[error("{0}")]
|
||||
Other(String),
|
||||
}
|
||||
|
||||
impl std::error::Error for Error {
|
||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||
match self {
|
||||
Error::Client(ref err) => Some(&**err),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Base error code for all chain errors.
|
||||
const BASE_ERROR: i64 = 3000;
|
||||
|
||||
|
||||
Reference in new issue
Block a user