Skip to main content

datum_cluster/
error.rs

1use std::{io, time::Duration};
2
3/// Result alias for `datum-cluster`.
4pub type ClusterResult<T> = Result<T, ClusterError>;
5
6/// Errors returned by `datum-cluster`.
7#[derive(Debug, thiserror::Error)]
8pub enum ClusterError {
9    /// Invalid node configuration.
10    #[error("invalid cluster config: {0}")]
11    InvalidConfig(String),
12    /// UDP transport failure.
13    #[error("cluster UDP transport failed: {0}")]
14    Io(#[from] io::Error),
15    /// Public state or event feed failed.
16    #[error("cluster feed failed: {0}")]
17    Feed(String),
18    /// The membership actor has stopped.
19    #[error("cluster node is stopped")]
20    Stopped,
21    /// The private foca engine returned an error.
22    #[error("cluster gossip failed: {0}")]
23    Gossip(String),
24    /// The request timed out.
25    #[error("cluster request timed out after {0:?}")]
26    Timeout(Duration),
27}
28
29impl From<datum::StreamError> for ClusterError {
30    fn from(error: datum::StreamError) -> Self {
31        Self::Feed(error.to_string())
32    }
33}