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    /// Zaino restart signal.
38    #[error("Restart Zaino")]
39    Restart,
40}
41
42#[allow(deprecated)]
43impl From<StateServiceError> for IndexerError {
44    fn from(value: StateServiceError) -> Self {
45        IndexerError::StateServiceError(Box::new(value))
46    }
47}
48
49#[allow(deprecated)]
50impl From<FetchServiceError> for IndexerError {
51    fn from(value: FetchServiceError) -> Self {
52        IndexerError::FetchServiceError(Box::new(value))
53    }
54}