event_scanner/robust_provider/
error.rs1use std::sync::Arc;
2
3use alloy::{
4 eips::BlockId,
5 transports::{RpcError, TransportErrorKind},
6};
7use thiserror::Error;
8use tokio::time::error as TokioError;
9
10#[derive(Error, Debug, Clone)]
11pub enum Error {
12 #[error("Operation timed out")]
13 Timeout,
14 #[error("RPC call failed after exhausting all retry attempts: {0}")]
15 RpcError(Arc<RpcError<TransportErrorKind>>),
16 #[error("Block not found, Block Id: {0}")]
17 BlockNotFound(BlockId),
18}
19
20impl From<RpcError<TransportErrorKind>> for Error {
21 fn from(err: RpcError<TransportErrorKind>) -> Self {
22 Error::RpcError(Arc::new(err))
23 }
24}
25
26impl From<TokioError::Elapsed> for Error {
27 fn from(_: TokioError::Elapsed) -> Self {
28 Error::Timeout
29 }
30}