mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 21:01:05 +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
@@ -522,7 +522,7 @@ impl<Factory: ServiceFactory> Components for FullComponents<Factory> {
|
||||
select_chain: Option<Self::SelectChain>,
|
||||
) -> Result<Self::ImportQueue, error::Error> {
|
||||
let select_chain = select_chain
|
||||
.ok_or_else(|| error::Error::from(error::ErrorKind::SelectChainRequired))?;
|
||||
.ok_or(error::Error::SelectChainRequired)?;
|
||||
Factory::build_full_import_queue(config, client, select_chain)
|
||||
}
|
||||
|
||||
|
||||
@@ -16,32 +16,49 @@
|
||||
|
||||
//! Errors that can occur during the service operation.
|
||||
|
||||
// Silence: `use of deprecated item 'std::error::Error::cause': replaced by Error::source, which can support downcasting`
|
||||
// https://github.com/paritytech/substrate/issues/1547
|
||||
#![allow(deprecated)]
|
||||
|
||||
use client;
|
||||
use network;
|
||||
use keystore;
|
||||
use consensus_common;
|
||||
use error_chain::*;
|
||||
|
||||
error_chain! {
|
||||
foreign_links {
|
||||
Client(client::error::Error) #[doc="Client error"];
|
||||
Io(::std::io::Error) #[doc="IO error"];
|
||||
/// Service Result typedef.
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
/// Service errors.
|
||||
#[derive(Debug, derive_more::Display, derive_more::From)]
|
||||
pub enum Error {
|
||||
/// Client error.
|
||||
Client(client::error::Error),
|
||||
/// IO error.
|
||||
Io(std::io::Error),
|
||||
/// Consensus error.
|
||||
Consensus(consensus_common::Error),
|
||||
/// Network error.
|
||||
Network(network::error::Error),
|
||||
/// Keystore error.
|
||||
Keystore(keystore::Error),
|
||||
/// Best chain selection strategy is missing.
|
||||
#[display(fmt="Best chain selection strategy (SelectChain) is not provided.")]
|
||||
SelectChainRequired,
|
||||
/// Other error.
|
||||
Other(String),
|
||||
}
|
||||
|
||||
impl<'a> From<&'a str> for Error {
|
||||
fn from(s: &'a str) -> Self {
|
||||
Error::Other(s.into())
|
||||
}
|
||||
}
|
||||
|
||||
links {
|
||||
Consensus(consensus_common::Error, consensus_common::ErrorKind) #[doc="Consensus error"];
|
||||
Network(network::error::Error, network::error::ErrorKind) #[doc="Network error"];
|
||||
Keystore(keystore::Error, keystore::ErrorKind) #[doc="Keystore error"];
|
||||
}
|
||||
|
||||
errors {
|
||||
SelectChainRequired {
|
||||
description("Best chain selection strategy (SelectChain) must be provided when starting full node or authority."),
|
||||
display("Best chain selection strategy (SelectChain) is not provided."),
|
||||
impl std::error::Error for Error {
|
||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||
match self {
|
||||
Error::Client(ref err) => Some(err),
|
||||
Error::Io(ref err) => Some(err),
|
||||
Error::Consensus(ref err) => Some(err),
|
||||
Error::Network(ref err) => Some(err),
|
||||
Error::Keystore(ref err) => Some(err),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ use runtime_primitives::traits::{Header, SaturatedConversion};
|
||||
use substrate_executor::NativeExecutor;
|
||||
use tel::{telemetry, SUBSTRATE_INFO};
|
||||
|
||||
pub use self::error::{ErrorKind, Error};
|
||||
pub use self::error::Error;
|
||||
pub use config::{Configuration, Roles, PruningMode};
|
||||
pub use chain_spec::{ChainSpec, Properties};
|
||||
pub use transaction_pool::txpool::{
|
||||
@@ -515,7 +515,7 @@ impl<C: Components> network::TransactionPool<ComponentExHash<C>, ComponentBlock<
|
||||
match self.pool.submit_one(&best_block_id, uxt) {
|
||||
Ok(hash) => Some(hash),
|
||||
Err(e) => match e.into_pool_error() {
|
||||
Ok(txpool::error::Error(txpool::error::ErrorKind::AlreadyImported(hash), _)) => {
|
||||
Ok(txpool::error::Error::AlreadyImported(hash)) => {
|
||||
hash.downcast::<ComponentExHash<C>>().ok()
|
||||
.map(|x| x.as_ref().clone())
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user