Skip to main content

common/coordinator/
error.rs

1/// Errors that can occur during write coordination.
2#[derive(Debug, Clone)]
3pub enum WriteError {
4    /// The write queue is full and backpressure is being applied
5    Backpressure,
6    /// The coordinator has been dropped/shutdown
7    Shutdown,
8    /// Error applying the write to the delta
9    ApplyError(u64, String),
10    /// Error flushing the delta to storage
11    FlushError(String),
12    /// Internal error
13    Internal(String),
14}
15
16impl std::fmt::Display for WriteError {
17    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
18        match self {
19            WriteError::Backpressure => write!(f, "write queue is full, backpressure applied"),
20            WriteError::Shutdown => write!(f, "coordinator has been dropped/shutdown"),
21            WriteError::ApplyError(epoch, msg) => {
22                write!(f, "error applying write @{}: {}", epoch, msg)
23            }
24            WriteError::FlushError(msg) => write!(f, "error flushing delta: {}", msg),
25            WriteError::Internal(msg) => write!(f, "internal error: {}", msg),
26        }
27    }
28}
29
30impl std::error::Error for WriteError {}
31
32/// Result type for write operations.
33pub type WriteResult<T> = Result<T, WriteError>;