reth_engine_primitives/error.rs
1use alloc::boxed::Box;
2use alloy_rpc_types_engine::ForkchoiceUpdateError;
3
4/// Represents all error cases when handling a new payload.
5///
6/// This represents all possible error cases that must be returned as JSON RCP errors back to the
7/// beacon node.
8#[derive(Debug, thiserror::Error)]
9pub enum BeaconOnNewPayloadError {
10 /// Thrown when the engine task is unavailable/stopped.
11 #[error("beacon consensus engine task stopped")]
12 EngineUnavailable,
13 /// An internal error occurred, not necessarily related to the payload.
14 #[error(transparent)]
15 Internal(Box<dyn core::error::Error + Send + Sync>),
16}
17
18impl BeaconOnNewPayloadError {
19 /// Create a new internal error.
20 pub fn internal<E: core::error::Error + Send + Sync + 'static>(e: E) -> Self {
21 Self::Internal(Box::new(e))
22 }
23}
24
25/// Represents error cases for an applied forkchoice update.
26///
27/// This represents all possible error cases, that must be returned as JSON RPC errors back to the
28/// beacon node.
29#[derive(Debug, thiserror::Error)]
30pub enum BeaconForkChoiceUpdateError {
31 /// Thrown when a forkchoice update resulted in an error.
32 #[error("forkchoice update error: {0}")]
33 ForkchoiceUpdateError(#[from] ForkchoiceUpdateError),
34 /// Thrown when the engine task is unavailable/stopped.
35 #[error("beacon consensus engine task stopped")]
36 EngineUnavailable,
37 /// An internal error occurred, not necessarily related to the update.
38 #[error(transparent)]
39 Internal(Box<dyn core::error::Error + Send + Sync>),
40}
41
42impl BeaconForkChoiceUpdateError {
43 /// Create a new internal error.
44 pub fn internal<E: core::error::Error + Send + Sync + 'static>(e: E) -> Self {
45 Self::Internal(Box::new(e))
46 }
47}