reth_beacon_consensus/engine/
error.rs1use crate::engine::hooks::EngineHookError;
2use alloy_rpc_types_engine::ForkchoiceUpdateError;
3use reth_errors::{DatabaseError, RethError};
4use reth_stages_api::PipelineError;
5
6pub type BeaconEngineResult<Ok> = Result<Ok, BeaconConsensusEngineError>;
8
9#[derive(Debug, thiserror::Error)]
14pub enum BeaconConsensusEngineError {
15 #[error("pipeline channel closed")]
17 PipelineChannelClosed,
18 #[error(transparent)]
20 Pipeline(#[from] Box<PipelineError>),
21 #[error("pruner channel closed")]
23 PrunerChannelClosed,
24 #[error(transparent)]
26 Hook(#[from] EngineHookError),
27 #[error(transparent)]
29 Common(#[from] RethError),
30}
31
32impl From<PipelineError> for BeaconConsensusEngineError {
34 fn from(e: PipelineError) -> Self {
35 Self::Pipeline(Box::new(e))
36 }
37}
38
39impl From<DatabaseError> for BeaconConsensusEngineError {
41 fn from(e: DatabaseError) -> Self {
42 Self::Common(e.into())
43 }
44}
45
46#[derive(Debug, thiserror::Error)]
51pub enum BeaconForkChoiceUpdateError {
52 #[error("forkchoice update error: {0}")]
54 ForkchoiceUpdateError(#[from] ForkchoiceUpdateError),
55 #[error("beacon consensus engine task stopped")]
57 EngineUnavailable,
58 #[error(transparent)]
60 Internal(Box<dyn core::error::Error + Send + Sync>),
61}
62
63impl BeaconForkChoiceUpdateError {
64 pub fn internal<E: core::error::Error + Send + Sync + 'static>(e: E) -> Self {
66 Self::Internal(Box::new(e))
67 }
68}
69
70impl From<RethError> for BeaconForkChoiceUpdateError {
71 fn from(e: RethError) -> Self {
72 Self::internal(e)
73 }
74}
75impl From<DatabaseError> for BeaconForkChoiceUpdateError {
76 fn from(e: DatabaseError) -> Self {
77 Self::internal(e)
78 }
79}