reth_primitives_traits/block/error.rs
1//! Error types for the `block` module.
2
3use crate::transaction::signed::RecoveryError;
4
5/// Type alias for [`BlockRecoveryError`] with a [`SealedBlock`](crate::SealedBlock) value.
6pub type SealedBlockRecoveryError<B> = BlockRecoveryError<crate::SealedBlock<B>>;
7
8/// Error when recovering a block from [`SealedBlock`](crate::SealedBlock) to
9/// [`RecoveredBlock`](crate::RecoveredBlock).
10///
11/// This error is returned when the block recovery fails and contains the erroneous block, because
12/// recovering a block takes ownership of the block.
13#[derive(Debug, Clone, thiserror::Error)]
14#[error("Failed to recover the block")]
15pub struct BlockRecoveryError<T>(pub T);
16
17impl<T> BlockRecoveryError<T> {
18 /// Create a new error.
19 pub const fn new(inner: T) -> Self {
20 Self(inner)
21 }
22
23 /// Unwrap the error and return the original value.
24 pub fn into_inner(self) -> T {
25 self.0
26 }
27}
28
29impl<T> From<BlockRecoveryError<T>> for RecoveryError {
30 fn from(_: BlockRecoveryError<T>) -> Self {
31 Self
32 }
33}