reth_errors/
error.rs
1use alloc::{boxed::Box, string::ToString};
2use core::fmt::Display;
3use reth_consensus::ConsensusError;
4use reth_execution_errors::BlockExecutionError;
5use reth_storage_errors::{db::DatabaseError, provider::ProviderError};
6
7pub type RethResult<T> = Result<T, RethError>;
9
10#[derive(Debug, thiserror::Error)]
16pub enum RethError {
17 #[error(transparent)]
19 Execution(#[from] BlockExecutionError),
20
21 #[error(transparent)]
23 Consensus(#[from] ConsensusError),
24
25 #[error(transparent)]
27 Database(#[from] DatabaseError),
28
29 #[error(transparent)]
31 Provider(#[from] ProviderError),
32
33 #[error(transparent)]
35 Other(Box<dyn core::error::Error + Send + Sync>),
36}
37
38impl RethError {
39 pub fn other<E>(error: E) -> Self
41 where
42 E: core::error::Error + Send + Sync + 'static,
43 {
44 Self::Other(Box::new(error))
45 }
46
47 pub fn msg(msg: impl Display) -> Self {
49 Self::Other(msg.to_string().into())
50 }
51}
52
53#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
55mod size_asserts {
56 use super::*;
57
58 macro_rules! static_assert_size {
59 ($t:ty, $sz:expr) => {
60 const _: [(); $sz] = [(); core::mem::size_of::<$t>()];
61 };
62 }
63
64 static_assert_size!(RethError, 56);
65 static_assert_size!(BlockExecutionError, 56);
66 static_assert_size!(ConsensusError, 48);
67 static_assert_size!(DatabaseError, 32);
68 static_assert_size!(ProviderError, 48);
69}