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:
Qinxuan Chen
2021-08-27 13:50:36 +08:00
committed by GitHub
parent 328cfbe633
commit a636b7a512
8 changed files with 39 additions and 74 deletions
+3 -4
View File
@@ -25,17 +25,16 @@ use jsonrpc_core as rpc;
pub type Result<T> = std::result::Result<T, Error>;
/// System RPC errors.
#[derive(Debug, derive_more::Display, derive_more::From)]
#[derive(Debug, thiserror::Error)]
pub enum Error {
/// Provided block range couldn't be resolved to a list of blocks.
#[display(fmt = "Node is not fully functional: {}", _0)]
#[error("Node is not fully functional: {}", .0)]
NotHealthy(Health),
/// Peer argument is malformatted.
#[error("{0}")]
MalformattedPeerArg(String),
}
impl std::error::Error for Error {}
/// Base code for all system errors.
const BASE_ERROR: i64 = 2000;