Skip to main content

nodedb_strict/
error.rs

1//! Error types for Binary Tuple encoding/decoding.
2
3use nodedb_types::columnar::ColumnType;
4
5/// Errors from Binary Tuple encoding and decoding.
6#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
7pub enum StrictError {
8    /// Wrong number of values for the schema.
9    #[error("expected {expected} values, got {got}")]
10    ValueCountMismatch { expected: usize, got: usize },
11
12    /// A value's type doesn't match the schema column type.
13    #[error("column '{column}': expected {expected}, got incompatible value")]
14    TypeMismatch {
15        column: String,
16        expected: ColumnType,
17    },
18
19    /// A non-nullable column received a null value with no default.
20    #[error("column '{0}' is NOT NULL and has no default")]
21    NullViolation(String),
22
23    /// Tuple bytes are too short to contain the header.
24    #[error("tuple too short: need at least {expected} bytes, got {got}")]
25    TruncatedTuple { expected: usize, got: usize },
26
27    /// Column index out of range for the schema.
28    #[error("column index {index} out of range (schema has {count} columns)")]
29    ColumnOutOfRange { index: usize, count: usize },
30
31    /// Offset table entry points outside the tuple.
32    #[error("corrupt offset table: offset {offset} exceeds tuple length {len}")]
33    CorruptOffset { offset: u32, len: usize },
34
35    /// Schema version in tuple is newer than the reader's schema.
36    #[error("tuple schema version {tuple_version} is newer than reader version {reader_version}")]
37    NewerSchemaVersion {
38        tuple_version: u16,
39        reader_version: u16,
40    },
41}