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:
Tomasz Drwięga
2019-05-24 11:35:31 +02:00
committed by Gavin Wood
parent 69ffec5822
commit c162fc5ff1
68 changed files with 951 additions and 1158 deletions
+36 -19
View File
@@ -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,
}
}
}