mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 12:37:57 +00:00
Expunge error-chain (feat. tomaka) (#2662)
* Remove error_chain * Expunge error-chain from rpc and service. * Expunge from transaction pool. * Expunge from node/cli * Expunge from keystore. * Remove some boilerplate. * Fix remaining stuff. * Improve on deprecation message. * Fix issues. * Fix trnsaction pool tests. * Fix the rest. * Fix borked merge. * Update lock
This commit is contained in:
committed by
Gavin Wood
parent
69ffec5822
commit
c162fc5ff1
@@ -16,40 +16,33 @@
|
||||
|
||||
//! System RPC module errors.
|
||||
|
||||
use error_chain::*;
|
||||
|
||||
use crate::rpc;
|
||||
use crate::errors;
|
||||
use crate::system::helpers::Health;
|
||||
|
||||
error_chain! {
|
||||
errors {
|
||||
/// Node is not fully functional
|
||||
NotHealthy(h: Health) {
|
||||
description("node is not healthy"),
|
||||
display("Node is not fully functional: {}", h)
|
||||
}
|
||||
/// System RPC Result type.
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
/// Not implemented yet
|
||||
Unimplemented {
|
||||
description("not yet implemented"),
|
||||
display("Method Not Implemented"),
|
||||
}
|
||||
}
|
||||
/// System RPC errors.
|
||||
#[derive(Debug, derive_more::Display, derive_more::From)]
|
||||
pub enum Error {
|
||||
/// Provided block range couldn't be resolved to a list of blocks.
|
||||
#[display(fmt = "Node is not fully functional: {}", _0)]
|
||||
NotHealthy(Health),
|
||||
}
|
||||
|
||||
const ERROR: i64 = 2000;
|
||||
impl std::error::Error for Error {}
|
||||
|
||||
/// Base code for all system errors.
|
||||
const BASE_ERROR: i64 = 2000;
|
||||
|
||||
impl From<Error> for rpc::Error {
|
||||
fn from(e: Error) -> Self {
|
||||
match e {
|
||||
Error(ErrorKind::Unimplemented, _) => errors::unimplemented(),
|
||||
Error(ErrorKind::NotHealthy(h), _) => rpc::Error {
|
||||
code: rpc::ErrorCode::ServerError(ERROR + 1),
|
||||
message: "node is not healthy".into(),
|
||||
data:serde_json::to_value(h).ok(),
|
||||
Error::NotHealthy(ref h) => rpc::Error {
|
||||
code: rpc::ErrorCode::ServerError(BASE_ERROR + 1),
|
||||
message: format!("{}", e),
|
||||
data: serde_json::to_value(h).ok(),
|
||||
},
|
||||
e => errors::internal(e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user