mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 21:11:07 +00:00
introduce errors with info (#1834)
This commit is contained in:
committed by
GitHub
parent
40ea09389c
commit
f345123748
@@ -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)) => {
|
||||
|
||||
Reference in New Issue
Block a user