iota_data_ingestion_core/
errors.rs

1// Copyright (c) 2024 IOTA Stiftung
2// SPDX-License-Identifier: Apache-2.0
3
4pub type IngestionResult<T, E = IngestionError> = core::result::Result<T, E>;
5
6// TODO: make first letter lower-case to all messages
7#[derive(Debug, thiserror::Error)]
8#[non_exhaustive]
9pub enum IngestionError {
10    #[error(transparent)]
11    ObjectStore(#[from] object_store::Error),
12
13    #[error(transparent)]
14    Url(#[from] url::ParseError),
15
16    #[error(transparent)]
17    Io(#[from] std::io::Error),
18
19    #[error(transparent)]
20    Bcs(#[from] bcs::Error),
21
22    #[error(transparent)]
23    Json(#[from] serde_json::Error),
24
25    #[error("grpc error: `{0}`")]
26    Grpc(String),
27
28    #[error("Register at least one worker pool")]
29    EmptyWorkerPool,
30
31    #[error("{component} shutdown error: `{msg}`")]
32    Shutdown { component: String, msg: String },
33
34    #[error("channel error: `{0}`")]
35    Channel(String),
36
37    #[error("checkpoint processing failed: `{0}`")]
38    CheckpointProcessing(String),
39
40    #[error("checkpoint hook processing failed: `{0}`")]
41    CheckpointHookProcessing(String),
42
43    #[error("progress store error: `{0}`")]
44    ProgressStore(String),
45
46    #[error("reducer error: `{0}`")]
47    Reducer(String),
48
49    #[error("deserialize checkpoint failed: `{0}`")]
50    DeserializeCheckpoint(String),
51
52    #[error(transparent)]
53    Upstream(#[from] anyhow::Error),
54
55    #[error("reading historical data failed: `{0}`")]
56    HistoryRead(String),
57
58    #[error("max downloaded checkpoints limit reached")]
59    MaxCheckpointsCapacityReached,
60
61    #[error("checkpoint not available yet")]
62    CheckpointNotAvailableYet,
63
64    #[error(transparent)]
65    Sdk(#[from] iota_types::iota_sdk_types_conversions::SdkTypeConversionError),
66}
67
68impl From<iota_grpc_types::proto::TryFromProtoError> for IngestionError {
69    fn from(err: iota_grpc_types::proto::TryFromProtoError) -> Self {
70        Self::Grpc(err.to_string())
71    }
72}
73
74impl From<iota_grpc_client::Error> for IngestionError {
75    fn from(err: iota_grpc_client::Error) -> Self {
76        Self::Grpc(err.to_string())
77    }
78}