mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 01:11:10 +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,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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user