use core::error::Error (#11317)

This commit is contained in:
Thomas Coratger
2024-09-29 18:47:48 +02:00
committed by GitHub
parent b8aeecae62
commit 55bf29e6d2
25 changed files with 90 additions and 101 deletions

View File

@ -90,7 +90,7 @@ pub enum BlobStoreError {
DecodeError(#[from] alloy_rlp::Error),
/// Other implementation specific error.
#[error(transparent)]
Other(Box<dyn std::error::Error + Send + Sync>),
Other(Box<dyn core::error::Error + Send + Sync>),
}
/// Keeps track of the size of the blob store.

View File

@ -10,7 +10,7 @@ pub type PoolResult<T> = Result<T, PoolError>;
///
/// For example during validation
/// [`TransactionValidator::validate_transaction`](crate::validate::TransactionValidator::validate_transaction)
pub trait PoolTransactionError: std::error::Error + Send + Sync {
pub trait PoolTransactionError: core::error::Error + Send + Sync {
/// Returns `true` if the error was caused by a transaction that is considered bad in the
/// context of the transaction pool and warrants peer penalization.
///
@ -19,8 +19,8 @@ pub trait PoolTransactionError: std::error::Error + Send + Sync {
}
// Needed for `#[error(transparent)]`
impl std::error::Error for Box<dyn PoolTransactionError> {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
impl core::error::Error for Box<dyn PoolTransactionError> {
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
(**self).source()
}
}
@ -63,7 +63,7 @@ pub enum PoolErrorKind {
/// Any other error that occurred while inserting/validating a transaction. e.g. IO database
/// error
#[error(transparent)]
Other(#[from] Box<dyn std::error::Error + Send + Sync>),
Other(#[from] Box<dyn core::error::Error + Send + Sync>),
}
// === impl PoolError ===
@ -75,7 +75,10 @@ impl PoolError {
}
/// Creates a new pool error with the `Other` kind.
pub fn other(hash: TxHash, error: impl Into<Box<dyn std::error::Error + Send + Sync>>) -> Self {
pub fn other(
hash: TxHash,
error: impl Into<Box<dyn core::error::Error + Send + Sync>>,
) -> Self {
Self { hash, kind: PoolErrorKind::Other(error.into()) }
}

View File

@ -51,7 +51,7 @@ pub enum TransactionValidationOutcome<T: PoolTransaction> {
/// this transaction from ever becoming valid.
Invalid(T, InvalidPoolTransactionError),
/// An error occurred while trying to validate the transaction
Error(TxHash, Box<dyn std::error::Error + Send + Sync>),
Error(TxHash, Box<dyn core::error::Error + Send + Sync>),
}
impl<T: PoolTransaction> TransactionValidationOutcome<T> {