Skip to main content

zainodlib/
error.rs

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