Skip to main content

molframe_core/provider/
error.rs

1//! Typed provider failures.
2
3use super::{ChunkId, DatasetId, LogicalRow};
4
5/// Failure to describe or produce an out-of-core chunk.
6#[derive(Clone, Debug, PartialEq, Eq, thiserror::Error)]
7#[non_exhaustive]
8pub enum ProviderError {
9    /// A dataset with rows was configured with no chunks.
10    #[error("dataset {dataset} has {rows} rows but no chunks")]
11    MissingChunks {
12        /// Invalid dataset.
13        dataset: DatasetId,
14        /// Declared logical rows.
15        rows: u64,
16    },
17    /// A chunk size of zero cannot make progress.
18    #[error("dataset {dataset} has a zero-row chunk size")]
19    ZeroChunkRows {
20        /// Invalid dataset.
21        dataset: DatasetId,
22    },
23    /// Dataset arithmetic exceeded its 64-bit identity space.
24    #[error("dataset {dataset} {field} overflows 64-bit provider identity")]
25    IdentityOverflow {
26        /// Dataset whose layout overflowed.
27        dataset: DatasetId,
28        /// Arithmetic field that overflowed.
29        field: &'static str,
30    },
31    /// Two datasets use the same stable identity.
32    #[error("dataset identity {dataset} is duplicated")]
33    DuplicateDataset {
34        /// Duplicated identity.
35        dataset: DatasetId,
36    },
37    /// Two dataset chunk ranges overlap.
38    #[error("chunk {chunk} belongs to more than one dataset")]
39    OverlappingChunkRange {
40        /// First overlapping chunk.
41        chunk: ChunkId,
42    },
43    /// A requested dataset does not exist in the catalog.
44    #[error("dataset {dataset} is not present in the catalog")]
45    UnknownDataset {
46        /// Missing identity.
47        dataset: DatasetId,
48    },
49    /// A requested chunk does not belong to the provider.
50    #[error("chunk {chunk} does not belong to dataset {dataset}")]
51    UnknownChunk {
52        /// Provider dataset.
53        dataset: DatasetId,
54        /// Requested chunk.
55        chunk: ChunkId,
56    },
57    /// A logical row does not fit in the requested dataset.
58    #[error("logical row {row} lies outside dataset {dataset}")]
59    LogicalRowOutOfRange {
60        /// Provider dataset.
61        dataset: DatasetId,
62        /// Invalid row.
63        row: LogicalRow,
64    },
65    /// A local row does not fit in its chunk.
66    #[error("local row {row} lies outside a chunk of {rows} rows")]
67    LocalRowOutOfRange {
68        /// Invalid local row.
69        row: u32,
70        /// Chunk row count.
71        rows: u32,
72    },
73    /// The supplied payload has a different row count than its descriptor.
74    #[error("chunk payload has {actual} rows but its descriptor declares {declared}")]
75    PayloadLengthMismatch {
76        /// Descriptor row count.
77        declared: u32,
78        /// Payload row count.
79        actual: u32,
80    },
81    /// A structure adapter cannot find the requested storage chunk.
82    #[error("structure storage chunk {index} is unavailable")]
83    StorageChunkUnavailable {
84        /// Structure-local chunk ordinal.
85        index: usize,
86    },
87    /// A structure has no requested model coordinate block.
88    #[error("structure model {model} has no direct coordinate block")]
89    ModelUnavailable {
90        /// Structure-local model ordinal.
91        model: u32,
92    },
93    /// A requested property is absent.
94    #[error("structure has no atom property named {name}")]
95    PropertyUnavailable {
96        /// Exact property name.
97        name: Box<str>,
98    },
99    /// A property does not align to the structure's atom rows.
100    #[error("property {name} has {actual} rows but the structure has {expected}")]
101    PropertyLengthMismatch {
102        /// Exact property name.
103        name: Box<str>,
104        /// Structure atom rows.
105        expected: u32,
106        /// Property rows.
107        actual: u32,
108    },
109    /// The structure does not carry a complete bond topology.
110    #[error("structure bond topology is unavailable")]
111    BondTopologyUnavailable,
112    /// A bond payload range does not fit the retained immutable bond table.
113    #[error("bond rows [{first}, {end}) exceed the retained table of {rows} rows")]
114    BondRangeUnavailable {
115        /// First requested source bond row.
116        first: u64,
117        /// Exclusive requested source bond row.
118        end: u64,
119        /// Rows retained by the source table.
120        rows: u64,
121    },
122}