Skip to main content

object_log/
error.rs

1use thiserror::Error;
2
3/// Errors returned by the object-log engine, storage adapters, and sequencer.
4#[derive(Debug, Error, Clone, PartialEq, Eq)]
5#[non_exhaustive]
6pub enum ObjectLogError {
7    /// An object key was empty or contained a `..` path component or `\0`.
8    #[error("invalid object key: {0}")]
9    InvalidObjectKey(String),
10    /// The storage layer was unreachable or returned an I/O error.
11    #[error("storage unavailable: {0}")]
12    StorageUnavailable(String),
13    /// A `get_range` request named a byte range outside the object, or inverted.
14    #[error("byte range out of bounds: {0}")]
15    RangeOutOfBounds(String),
16    /// The index referenced an object that is no longer present in storage.
17    #[error("missing object: {0}")]
18    MissingObject(String),
19    /// A produce batch was malformed (e.g. empty, or below the configured floor).
20    #[error("invalid produce batch: {0}")]
21    InvalidBatch(String),
22    /// The sequencer rejected or failed to process a commit/lookup.
23    #[error("sequencer error: {0}")]
24    Sequencer(String),
25
26    /// The partition's fence epoch moved past the write's epoch, so the write was
27    /// not committed. Retrying at the same epoch cannot succeed.
28    ///
29    /// Produced by a sequencer's [`rejection_error`](crate::Sequencer::rejection_error)
30    /// (for example [`ManifestSequencer`](crate::ManifestSequencer)); the engine
31    /// never constructs it.
32    #[error(
33        "partition {partition} is fenced at epoch {current}; the write at epoch {epoch} was not committed"
34    )]
35    Fenced {
36        /// Partition whose fence rejected the write.
37        partition: String,
38        /// Epoch the write was produced at.
39        epoch: u64,
40        /// Fence epoch the partition's index holds.
41        current: u64,
42    },
43    /// Durable-ops budget admission failed (`BudgetMode::FailClosed` or timed out).
44    #[error("durable-ops budget exceeded: {0}")]
45    BudgetExceeded(String),
46    /// Invalid engine or budget configuration.
47    #[error("invalid configuration: {0}")]
48    InvalidConfig(String),
49}
50
51impl From<std::io::Error> for ObjectLogError {
52    fn from(value: std::io::Error) -> Self {
53        Self::StorageUnavailable(value.to_string())
54    }
55}