Skip to main content

kuberic_core/
error.rs

1use crate::types::Epoch;
2
3#[derive(Debug, thiserror::Error)]
4pub enum KubericError {
5    /// This replica is not the primary. Redirect client.
6    #[error("not primary")]
7    NotPrimary,
8
9    /// Primary does not have write quorum. Retry later.
10    #[error("no write quorum")]
11    NoWriteQuorum,
12
13    /// Reconfiguration in progress. Retry later.
14    #[error("reconfiguration pending")]
15    ReconfigurationPending,
16
17    /// Operation from a stale epoch was rejected.
18    #[error("stale epoch: got {got:?}, current {current:?}")]
19    StaleEpoch { got: Epoch, current: Epoch },
20
21    /// Operation was cancelled via CancellationToken.
22    #[error("cancelled")]
23    Cancelled,
24
25    /// The replica/partition is closed or shutting down.
26    #[error("closed")]
27    Closed,
28
29    /// Internal error (IO, serialization, etc.)
30    #[error(transparent)]
31    Internal(#[from] Box<dyn std::error::Error + Send + Sync>),
32}
33
34pub type Result<T> = std::result::Result<T, KubericError>;