feat: add blockexecution msg fn (#8478)

This commit is contained in:
Matthias Seitz
2024-05-29 16:52:45 +02:00
committed by GitHub
parent 13c914598e
commit 1d428cbba6

View File

@ -11,6 +11,7 @@
use reth_consensus::ConsensusError;
use reth_primitives::{revm_primitives::EVMError, BlockNumHash, PruneSegmentError, B256};
use reth_storage_errors::provider::ProviderError;
use std::fmt::Display;
use thiserror::Error;
pub mod trie;
@ -118,7 +119,7 @@ pub enum BlockExecutionError {
/// Error when fetching latest block state.
#[error(transparent)]
LatestBlock(#[from] ProviderError),
/// Optimism Block Executor Errors
/// Arbitrary Block Executor Errors
#[error(transparent)]
Other(Box<dyn std::error::Error + Send + Sync>),
}
@ -132,6 +133,11 @@ impl BlockExecutionError {
Self::Other(Box::new(error))
}
/// Create a new [BlockExecutionError::Other] from a given message.
pub fn msg(msg: impl Display) -> Self {
Self::Other(msg.to_string().into())
}
/// Returns the inner `BlockValidationError` if the error is a validation error.
pub const fn as_validation(&self) -> Option<&BlockValidationError> {
match self {