Skip to main content

zainodlib/
error.rs

1//! Hold error types for the Indexer and related functionality.
2
3use zaino_fetch::jsonrpsee::error::TransportError;
4use zaino_serve::server::error::ServerError;
5
6use zaino_state::NodeBackedIndexerServiceError;
7
8/// Zingo-Indexer errors.
9#[derive(Debug, thiserror::Error)]
10pub enum IndexerError {
11    /// Server based errors.
12    #[error("Server error: {0}")]
13    ServerError(#[from] ServerError),
14    /// Configuration errors.
15    #[error("Configuration error: {0}")]
16    ConfigError(String),
17    /// JSON RPSee connector errors.
18    #[error("JSON RPSee connector error: {0}")]
19    TransportError(#[from] TransportError),
20    /// NodeBackedIndexerService errors.
21    #[error("NodeBackedIndexerService error: {0}")]
22    NodeBackedIndexerServiceError(Box<NodeBackedIndexerServiceError>),
23    /// HTTP related errors due to invalid URI.
24    #[error("HTTP error: Invalid URI {0}")]
25    HttpError(#[from] http::Error),
26    /// Returned from tokio joinhandles..
27    #[error("Join handle error: Invalid URI {0}")]
28    TokioJoinError(#[from] tokio::task::JoinError),
29    /// Custom indexor errors.
30    #[error("Misc indexer error: {0}")]
31    MiscIndexerError(String),
32    /// Metrics endpoint errors.
33    #[cfg(feature = "prometheus")]
34    #[error("Metrics error: {0}")]
35    MetricsError(String),
36    /// Zaino restart signal.
37    #[error("Restart Zaino")]
38    Restart,
39}
40
41impl From<NodeBackedIndexerServiceError> for IndexerError {
42    fn from(value: NodeBackedIndexerServiceError) -> Self {
43        IndexerError::NodeBackedIndexerServiceError(Box::new(value))
44    }
45}