mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 04:41:02 +00:00
Replace error-chain for client error (#2231)
* WIP: convert client error * Remove error_chain for client error * Ignore tx-pool error deprecation warning * Update Cargo.lock files * Fix tests * Increment impl_version * Derive From impls, remove allow(missing_docs) * Remove space * Remove redundant into()s * Blockchain Error source * Bump impl version
This commit is contained in:
committed by
Bastian Köcher
parent
1e0c1d8850
commit
7f59cdb900
@@ -23,7 +23,7 @@ use runtime_primitives::generic::BlockId;
|
||||
use runtime_primitives::Justification;
|
||||
use consensus::well_known_cache_keys;
|
||||
|
||||
use crate::error::{ErrorKind, Result};
|
||||
use crate::error::{Error, Result};
|
||||
|
||||
/// Blockchain database header backend. Does not perform any validation.
|
||||
pub trait HeaderBackend<Block: BlockT>: Send + Sync {
|
||||
@@ -56,19 +56,19 @@ pub trait HeaderBackend<Block: BlockT>: Send + Sync {
|
||||
|
||||
/// Get block header. Returns `UnknownBlock` error if block is not found.
|
||||
fn expect_header(&self, id: BlockId<Block>) -> Result<Block::Header> {
|
||||
self.header(id)?.ok_or_else(|| ErrorKind::UnknownBlock(format!("{}", id)).into())
|
||||
self.header(id)?.ok_or_else(|| Error::UnknownBlock(format!("{}", id)))
|
||||
}
|
||||
|
||||
/// Convert an arbitrary block ID into a block number. Returns `UnknownBlock` error if block is not found.
|
||||
fn expect_block_number_from_id(&self, id: &BlockId<Block>) -> Result<NumberFor<Block>> {
|
||||
self.block_number_from_id(id)
|
||||
.and_then(|n| n.ok_or_else(|| ErrorKind::UnknownBlock(format!("{}", id)).into()))
|
||||
.and_then(|n| n.ok_or_else(|| Error::UnknownBlock(format!("{}", id))))
|
||||
}
|
||||
|
||||
/// Convert an arbitrary block ID into a block hash. Returns `UnknownBlock` error if block is not found.
|
||||
fn expect_block_hash_from_id(&self, id: &BlockId<Block>) -> Result<Block::Hash> {
|
||||
self.block_hash_from_id(id)
|
||||
.and_then(|n| n.ok_or_else(|| ErrorKind::UnknownBlock(format!("{}", id)).into()))
|
||||
.and_then(|n| n.ok_or_else(|| Error::UnknownBlock(format!("{}", id))))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ pub fn tree_route<Block: BlockT, Backend: HeaderBackend<Block>>(
|
||||
let load_header = |id: BlockId<Block>| {
|
||||
match backend.header(id) {
|
||||
Ok(Some(hdr)) => Ok(hdr),
|
||||
Ok(None) => Err(ErrorKind::UnknownBlock(format!("Unknown block {:?}", id)).into()),
|
||||
Ok(None) => Err(Error::UnknownBlock(format!("Unknown block {:?}", id))),
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user