Skip to content

Commit

Permalink
feat(pontos): add new error for starknet client
Browse files Browse the repository at this point in the history
  • Loading branch information
glihm committed Oct 18, 2023
1 parent bad1b6a commit a8e8c58
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions crates/pontos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub mod storage;

use crate::storage::types::BlockIndexingStatus;
use anyhow::Result;
use ark_starknet::client::StarknetClient;
use ark_starknet::client::{StarknetClient, StarknetClientError};
use event_handler::EventHandler;
use managers::{BlockManager, ContractManager, EventManager, PendingBlockData, TokenManager};
use starknet::core::types::*;
Expand All @@ -18,9 +18,10 @@ use tracing::{debug, error, info, trace, warn};
pub type IndexerResult<T> = Result<T, IndexerError>;

/// Generic errors for Pontos.
#[derive(Debug, Clone)]
#[derive(Debug)]
pub enum IndexerError {
StorageError(StorageError),
Starknet(StarknetClientError),
Anyhow(String),
}

Expand All @@ -30,6 +31,12 @@ impl From<StorageError> for IndexerError {
}
}

impl From<StarknetClientError> for IndexerError {
fn from(e: StarknetClientError) -> Self {
IndexerError::Starknet(e)
}
}

impl From<anyhow::Error> for IndexerError {
fn from(e: anyhow::Error) -> Self {
IndexerError::Anyhow(e.to_string())
Expand All @@ -40,6 +47,7 @@ impl fmt::Display for IndexerError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
IndexerError::StorageError(e) => write!(f, "Storage Error occurred: {}", e),
IndexerError::Starknet(e) => write!(f, "Starknet Error occurred: {}", e),
IndexerError::Anyhow(s) => write!(f, "An error occurred: {}", s),
}
}
Expand Down

0 comments on commit a8e8c58

Please sign in to comment.