-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
215 additions
and
95 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,83 @@ | ||
use tokio::sync::mpsc::error::SendError; | ||
|
||
use crate::{clients::common::ClientError, synchronizer::error::SynchronizerError}; | ||
|
||
use super::types::IndexerTaskMessage; | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
pub enum IndexerError { | ||
#[error("failed to create indexer")] | ||
CreationFailure(#[source] anyhow::Error), | ||
#[error(transparent)] | ||
SyncingTaskError(#[from] SyncingTaskError), | ||
#[error("failed to retrieve blobscan's sync state")] | ||
BlobscanSyncStateRetrievalError(#[source] ClientError), | ||
#[error("sync task message send failure")] | ||
SyncingTaskMessageSendFailure(#[from] SendError<IndexerTaskMessage>), | ||
} | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
pub enum SyncingTaskError { | ||
#[error("an error ocurred while syncing historical data")] | ||
HistoricalSyncingTaskError(#[from] HistoricalSyncingError), | ||
#[error("an error occurred while syncing realtime data")] | ||
RealtimeSyncingTaskError(#[from] RealtimeSyncingError), | ||
} | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
pub enum HistoricalSyncingError { | ||
#[error(transparent)] | ||
SynchronizerError(#[from] SynchronizerError), | ||
} | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
pub enum RealtimeSyncingError { | ||
#[error("an error ocurred while receiving beacon events")] | ||
BeaconEventsConnectionFailure(#[from] reqwest_eventsource::Error), | ||
#[error("failed to subscribe to beacon events")] | ||
BeaconEventsSubscriptionError(#[source] ClientError), | ||
#[error("unexpected event \"{0}\" received")] | ||
UnexpectedBeaconEvent(String), | ||
#[error(transparent)] | ||
ReqwestEventSourceError(#[from] reqwest_eventsource::Error), | ||
BeaconEventProcessingError(#[from] BeaconEventError), | ||
} | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
pub enum BeaconEventError { | ||
#[error("failed to handle \"chain_reorged\" event")] | ||
ChainReorged(#[from] ChainReorgedEventHandlingError), | ||
#[error("failed to handle \"head\" event")] | ||
HeadBlock(#[from] HeadBlockEventHandlingError), | ||
#[error("failed to handle \"finalized_checkpoint\" event")] | ||
FinalizedCheckpoint(#[from] FinalizedBlockEventHandlingError), | ||
} | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
pub enum FinalizedBlockEventHandlingError { | ||
#[error(transparent)] | ||
ClientError(#[from] ClientError), | ||
EventDeserializationFailure(#[from] serde_json::Error), | ||
#[error("failed to retrieve finalized block {0}")] | ||
BlockRetrievalError(String, #[source] ClientError), | ||
#[error(transparent)] | ||
Other(#[from] anyhow::Error), | ||
#[error("failed to update blobscan's last finalized block")] | ||
BlobscanSyncStateUpdateError(#[source] ClientError), | ||
} | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
pub enum ChainReorgedEventHandlingError { | ||
#[error(transparent)] | ||
EventDeserializationFailure(#[from] serde_json::Error), | ||
#[error("failed to retrieve reorged block {0}")] | ||
BlockRetrievalError(String, #[source] ClientError), | ||
#[error("failed to handle reorged of depth {0} starting at block {1}")] | ||
ReorgedHandlingFailure(u32, String, #[source] ClientError), | ||
} | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
pub enum HeadBlockEventHandlingError { | ||
#[error(transparent)] | ||
EventDeserializationFailure(#[from] serde_json::Error), | ||
#[error(transparent)] | ||
SynchronizerError(#[from] SynchronizerError), | ||
#[error("{0}")] | ||
SerdeError(#[from] serde_json::Error), | ||
#[error("Unexpected event \"{event}\" received")] | ||
UnexpectedEvent { event: String }, | ||
} |
Oops, something went wrong.