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    /// Durable-ops budget admission failed (`BudgetMode::FailClosed` or timed out).
26    #[error("durable-ops budget exceeded: {0}")]
27    BudgetExceeded(String),
28    /// Invalid engine or budget configuration.
29    #[error("invalid configuration: {0}")]
30    InvalidConfig(String),
31}
32
33impl From<std::io::Error> for ObjectLogError {
34    fn from(value: std::io::Error) -> Self {
35        Self::StorageUnavailable(value.to_string())
36    }
37}