datacake_eventual_consistency/
error.rs

1use std::error::Error;
2use std::fmt::Debug;
3use std::io;
4use std::net::SocketAddr;
5
6use datacake_node::ConsistencyError;
7use datacake_rpc::Status;
8use thiserror::Error;
9
10use crate::storage::BulkMutationError;
11
12#[derive(Debug, Error)]
13/// A wrapping error for the store which can potentially fail under situations.
14pub enum StoreError<E: Error + Send + 'static> {
15    #[error("{0}")]
16    /// An error has occurred within Chitchat.
17    ChitChatError(String),
18
19    #[error("An unknown error occurred during the operation: {0}")]
20    /// An error has occurred which datacake was not expecting nad from
21    /// an unknown source.
22    UnknownError(anyhow::Error),
23
24    #[error(
25        "A failure occurred within the user provided `DataStore` implementation: {0}"
26    )]
27    /// A failure has occurred within the provided storage system causing the operation
28    /// to fail.
29    StorageError(#[from] E),
30
31    #[error(
32        "A failure occurred within the user provided `DataStore` implementation on a bulk operation: {0}"
33    )]
34    /// A failure has occurred within the provided storage system causing the operation
35    /// to fail.
36    ///
37    /// This error however, includes the set of doc ids which *were* successfully completed,
38    /// this can be used to maintain partial and incremental updates despite and error, otherwise
39    /// bulk storage operations must be entirely atomic if they do not specify the successful IDs.
40    BulkStorageError(#[from] BulkMutationError<E>),
41
42    #[error("Failed to complete operation due to consistency level failure: {0}")]
43    /// The operation succeeded on the local node but failed to meet the required
44    /// consistency level within the timeout period. (2 seconds)
45    ConsistencyError(ConsistencyError),
46
47    #[error("Transport Error: ({0}) - {1}")]
48    /// An error occurred when attempting to open a connection or listen on a given address.
49    TransportError(SocketAddr, io::Error),
50
51    #[error("Rpc Error: ({0}) - {1}")]
52    /// An error occurred during RPC communication with other nodes.
53    RpcError(SocketAddr, Status),
54}