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    #[error(
29        "partition {partition} is fenced at epoch {current}; the write at epoch {epoch} was not committed"
30    )]
31    Fenced {
32        /// Partition whose fence rejected the write.
33        partition: String,
34        /// Epoch the write was produced at.
35        epoch: u64,
36        /// Fence epoch the partition's index holds.
37        current: u64,
38    },
39    /// Durable-ops budget admission failed (`BudgetMode::FailClosed` or timed out).
40    #[error("durable-ops budget exceeded: {0}")]
41    BudgetExceeded(String),
42    /// Invalid engine or budget configuration.
43    #[error("invalid configuration: {0}")]
44    InvalidConfig(String),
45}
46
47impl From<std::io::Error> for ObjectLogError {
48    fn from(value: std::io::Error) -> Self {
49        Self::StorageUnavailable(value.to_string())
50    }
51}