reth_beacon_consensus/engine/
error.rsuse crate::engine::hooks::EngineHookError;
use alloy_rpc_types_engine::ForkchoiceUpdateError;
use reth_errors::{DatabaseError, RethError};
use reth_stages_api::PipelineError;
pub type BeaconEngineResult<Ok> = Result<Ok, BeaconConsensusEngineError>;
#[derive(Debug, thiserror::Error)]
pub enum BeaconConsensusEngineError {
#[error("pipeline channel closed")]
PipelineChannelClosed,
#[error(transparent)]
Pipeline(#[from] Box<PipelineError>),
#[error("pruner channel closed")]
PrunerChannelClosed,
#[error(transparent)]
Hook(#[from] EngineHookError),
#[error(transparent)]
Common(#[from] RethError),
}
impl From<PipelineError> for BeaconConsensusEngineError {
fn from(e: PipelineError) -> Self {
Self::Pipeline(Box::new(e))
}
}
impl From<DatabaseError> for BeaconConsensusEngineError {
fn from(e: DatabaseError) -> Self {
Self::Common(e.into())
}
}
#[derive(Debug, thiserror::Error)]
pub enum BeaconForkChoiceUpdateError {
#[error("forkchoice update error: {0}")]
ForkchoiceUpdateError(#[from] ForkchoiceUpdateError),
#[error("beacon consensus engine task stopped")]
EngineUnavailable,
#[error(transparent)]
Internal(Box<dyn core::error::Error + Send + Sync>),
}
impl BeaconForkChoiceUpdateError {
pub fn internal<E: core::error::Error + Send + Sync + 'static>(e: E) -> Self {
Self::Internal(Box::new(e))
}
}
impl From<RethError> for BeaconForkChoiceUpdateError {
fn from(e: RethError) -> Self {
Self::internal(e)
}
}
impl From<DatabaseError> for BeaconForkChoiceUpdateError {
fn from(e: DatabaseError) -> Self {
Self::internal(e)
}
}
#[derive(Debug, thiserror::Error)]
pub enum BeaconOnNewPayloadError {
#[error("beacon consensus engine task stopped")]
EngineUnavailable,
#[error(transparent)]
Internal(Box<dyn core::error::Error + Send + Sync>),
}
impl BeaconOnNewPayloadError {
pub fn internal<E: core::error::Error + Send + Sync + 'static>(e: E) -> Self {
Self::Internal(Box::new(e))
}
}