mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-06 05:38:00 +00:00
use thiserror instead of derive_more for error handling (#10696)
* use thiserror instead of derive_more for error handling Signed-off-by: koushiro <koushiro.cqx@gmail.com> * Update utils/prometheus/src/lib.rs * Update utils/prometheus/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -78,26 +78,19 @@ impl<TBlock: Block> PrettyPrinter<TBlock> for DebugPrinter {
|
||||
}
|
||||
|
||||
/// Aggregated error for `Inspector` operations.
|
||||
#[derive(Debug, derive_more::From, derive_more::Display)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum Error {
|
||||
/// Could not decode Block or Extrinsic.
|
||||
Codec(codec::Error),
|
||||
#[error(transparent)]
|
||||
Codec(#[from] codec::Error),
|
||||
/// Error accessing blockchain DB.
|
||||
Blockchain(sp_blockchain::Error),
|
||||
#[error(transparent)]
|
||||
Blockchain(#[from] sp_blockchain::Error),
|
||||
/// Given block has not been found.
|
||||
#[error("{0}")]
|
||||
NotFound(String),
|
||||
}
|
||||
|
||||
impl std::error::Error for Error {
|
||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||
match *self {
|
||||
Self::Codec(ref e) => Some(e),
|
||||
Self::Blockchain(ref e) => Some(e),
|
||||
Self::NotFound(_) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A helper trait to access block headers and bodies.
|
||||
pub trait ChainAccess<TBlock: Block>: HeaderBackend<TBlock> + BlockBackend<TBlock> {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user