Skip to main content

waratah_storage/
error.rs

1//! Typed storage-layer errors.
2
3use thiserror::Error;
4
5use crate::types::PartitionAxis;
6
7/// Errors returned by the storage brick and its backends.
8#[derive(Debug, Error)]
9pub enum StorageError {
10    /// A partition axis name outside `s` / `p` / `o`.
11    #[error("unknown partition axis: {0}")]
12    UnknownAxis(String),
13
14    /// The requested index is not one of the two owned by this partition axis.
15    #[error("index {index} is not owned by partition axis {axis}")]
16    PermutationNotOwned {
17        /// Column-family name of the requested permutation.
18        index: &'static str,
19        /// Axis this store was opened for.
20        axis: PartitionAxis,
21    },
22
23    /// A hashed term was not found in the string registry shard.
24    #[error("string registry miss for hash {0:#x}")]
25    RegistryMiss(u128),
26
27    /// RocksDB or native backend failure (Phase 2+).
28    #[error("backend error: {0}")]
29    Backend(String),
30
31    /// Corrupt or un-decodable stored bytes.
32    #[error("corrupt data: {0}")]
33    Corrupt(String),
34
35    /// The value can only be decoded with the blob store's payload (geo
36    /// literals and other plugin-encoded blob-backed terms carry no bytes
37    /// inline). This is not corruption: the caller must fetch the payload
38    /// (or use a cached lexical) and decode through the plugin registry.
39    #[error("value requires the blob store to decode: {0}")]
40    RequiresBlobStore(String),
41
42    /// Named-graph catalog RPCs and CFs exist only on the S axis.
43    #[error("named-graph catalog is S-axis only (this store is {0})")]
44    CatalogNotOnAxis(PartitionAxis),
45
46    /// Geometry-index RPCs and the CF exist only on the O axis.
47    #[error("geometry index is O-axis only (this store is {0})")]
48    GeoIndexNotOnAxis(PartitionAxis),
49
50    /// Temporal-index RPCs and the CF exist only on the O axis.
51    #[error("temporal index is O-axis only (this store is {0})")]
52    TemporalIndexNotOnAxis(PartitionAxis),
53
54    /// Text-index RPCs exist only on the O axis.
55    #[error("text index is O-axis only (this store is {0})")]
56    TextIndexNotOnAxis(PartitionAxis),
57
58    /// Catalog keys must be IRI named nodes (never the RDF default graph or blanks).
59    #[error("invalid named-graph catalog term: {0}")]
60    InvalidCatalogGraph(String),
61
62    /// Domain-count distinct modes are only defined for 4-slot
63    /// permutations. TSG's third component is G, so the distinct-term
64    /// counter would read the graph slot (that is `DistinctGraphs`' job,
65    /// and it errors on default-graph rows whose G region is empty), and
66    /// the distinct-graph counter would read past it (always empty, always
67    /// one "graph"). The partition RPC already refuses TSG for domain
68    /// counts; this is the in-process gate for direct storage callers.
69    /// `Rows` mode remains servable on TSG.
70    #[error(
71        "domain-count distinct modes are not served on TSG (use a 4-slot permutation, or Rows mode)"
72    )]
73    DistinctCountsNotOnTsg,
74
75    /// An internally synchronized backend's lock was poisoned by a panicked
76    /// writer (in-memory backend only; RocksDB needs no external lock).
77    #[error("storage lock poisoned")]
78    LockPoisoned,
79}