introduce errors with info (#1834)

This commit is contained in:
Bernhard Schuster
2020-10-27 08:10:03 +01:00
committed by GitHub
parent 40ea09389c
commit f345123748
58 changed files with 1983 additions and 2030 deletions
+13 -3
View File
@@ -27,9 +27,12 @@
//! * Last finalized block number
//! * Ancestors
#![deny(unused_crate_dependencies, unused_results)]
#![warn(missing_docs)]
use polkadot_subsystem::{
FromOverseer, OverseerSignal,
SpawnedSubsystem, Subsystem, SubsystemResult, SubsystemContext,
SpawnedSubsystem, Subsystem, SubsystemResult, SubsystemError, SubsystemContext,
messages::ChainApiMessage,
};
use polkadot_node_subsystem_util::{
@@ -61,8 +64,12 @@ impl<Client, Context> Subsystem<Context> for ChainApiSubsystem<Client> where
Context: SubsystemContext<Message = ChainApiMessage>
{
fn start(self, ctx: Context) -> SpawnedSubsystem {
let future = run(ctx, self)
.map_err(|e| SubsystemError::with_origin("chain-api", e))
.map(|_| ())
.boxed();
SpawnedSubsystem {
future: run(ctx, self).map(|_| ()).boxed(),
future,
name: "chain-api-subsystem",
}
}
@@ -112,7 +119,10 @@ where
let maybe_header = subsystem.client.header(BlockId::Hash(hash));
match maybe_header {
// propagate the error
Err(e) => Some(Err(e.to_string().into())),
Err(e) => {
let e = e.to_string().into();
Some(Err(e))
},
// fewer than `k` ancestors are available
Ok(None) => None,
Ok(Some(header)) => {