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
6#[allow(deprecated)]
7use zaino_state::{FetchServiceError, StateServiceError};
8
9/// Zingo-Indexer errors.
10#[derive(Debug, thiserror::Error)]
11#[allow(deprecated)]
12pub enum IndexerError {
13    /// Server based errors.
14    #[error("Server error: {0}")]
15    ServerError(#[from] ServerError),
16    /// Configuration errors.
17    #[error("Configuration error: {0}")]
18    ConfigError(String),
19    /// JSON RPSee connector errors.
20    #[error("JSON RPSee connector error: {0}")]
21    TransportError(#[from] TransportError),
22    /// FetchService errors.
23    #[error("FetchService error: {0}")]
24    FetchServiceError(Box<FetchServiceError>),
25    /// FetchService errors.
26    #[error("StateService error: {0}")]
27    StateServiceError(Box<StateServiceError>),
28    /// HTTP related errors due to invalid URI.
29    #[error("HTTP error: Invalid URI {0}")]
30    HttpError(#[from] http::Error),
31    /// Returned from tokio joinhandles..
32    #[error("Join handle error: Invalid URI {0}")]
33    TokioJoinError(#[from] tokio::task::JoinError),
34    /// Custom indexor errors.
35    #[error("Misc indexer error: {0}")]
36    MiscIndexerError(String),
37    /// Metrics endpoint errors.
38    #[cfg(feature = "prometheus")]
39    #[error("Metrics error: {0}")]
40    MetricsError(String),
41    /// Zaino restart signal.
42    #[error("Restart Zaino")]
43    Restart,
44}
45
46#[allow(deprecated)]
47impl From<StateServiceError> for IndexerError {
48    fn from(value: StateServiceError) -> Self {
49        IndexerError::StateServiceError(Box::new(value))
50    }
51}
52
53#[allow(deprecated)]
54impl From<FetchServiceError> for IndexerError {
55    fn from(value: FetchServiceError) -> Self {
56        IndexerError::FetchServiceError(Box::new(value))
57    }
58}