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:
Qinxuan Chen
2022-01-26 03:48:46 +08:00
committed by GitHub
parent 38d94d6323
commit e956c2e1c7
47 changed files with 378 additions and 357 deletions
+10 -9
View File
@@ -491,33 +491,34 @@ fn aura_err<B: BlockT>(error: Error<B>) -> Error<B> {
}
/// Aura Errors
#[derive(derive_more::Display, Debug)]
#[derive(Debug, thiserror::Error)]
pub enum Error<B: BlockT> {
/// Multiple Aura pre-runtime headers
#[display(fmt = "Multiple Aura pre-runtime headers")]
#[error("Multiple Aura pre-runtime headers")]
MultipleHeaders,
/// No Aura pre-runtime digest found
#[display(fmt = "No Aura pre-runtime digest found")]
#[error("No Aura pre-runtime digest found")]
NoDigestFound,
/// Header is unsealed
#[display(fmt = "Header {:?} is unsealed", _0)]
#[error("Header {0:?} is unsealed")]
HeaderUnsealed(B::Hash),
/// Header has a bad seal
#[display(fmt = "Header {:?} has a bad seal", _0)]
#[error("Header {0:?} has a bad seal")]
HeaderBadSeal(B::Hash),
/// Slot Author not found
#[display(fmt = "Slot Author not found")]
#[error("Slot Author not found")]
SlotAuthorNotFound,
/// Bad signature
#[display(fmt = "Bad signature on {:?}", _0)]
#[error("Bad signature on {0:?}")]
BadSignature(B::Hash),
/// Client Error
#[error(transparent)]
Client(sp_blockchain::Error),
/// Unknown inherent error for identifier
#[display(fmt = "Unknown inherent error for identifier: {}", "String::from_utf8_lossy(_0)")]
#[error("Unknown inherent error for identifier: {}", String::from_utf8_lossy(.0))]
UnknownInherentError(sp_inherents::InherentIdentifier),
#[display(fmt = "Inherent error: {}", _0)]
/// Inherents Error
#[error("Inherent error: {0}")]
Inherent(sp_inherents::Error),
}