alopex_core/columnar/
error.rs1use thiserror::Error;
3
4use crate::Error as CoreError;
5
6pub type Result<T> = std::result::Result<T, ColumnarError>;
8
9#[derive(Debug, Error)]
11pub enum ColumnarError {
12 #[error("checksum mismatch")]
14 ChecksumMismatch,
15 #[error("unsupported format version: found={found}, expected={expected}")]
17 UnsupportedFormatVersion {
18 found: u16,
20 expected: u16,
22 },
23 #[error("requires V08 chunked layout")]
25 RequiresV08ChunkedLayout,
26 #[error("unsupported compression: {algorithm}")]
28 UnsupportedCompression {
29 algorithm: String,
31 },
32 #[error("memory limit exceeded: limit={limit}, requested={requested}")]
34 MemoryLimitExceeded {
35 limit: usize,
37 requested: usize,
39 },
40 #[error("invalid format: {0}")]
42 InvalidFormat(String),
43 #[error("not found")]
45 NotFound,
46 #[error("transaction conflict")]
48 TxnConflict,
49 #[error("row group too large: size={size}, max={max}")]
51 RowGroupTooLarge {
52 size: u64,
54 max: u64,
56 },
57 #[error("not in in-memory mode")]
59 NotInMemoryMode,
60 #[error("table not found: {table}")]
62 TableNotFound {
63 table: String,
65 },
66 #[error("corrupted segment: {reason}")]
68 CorruptedSegment {
69 reason: String,
71 },
72 #[error("encoding error: {reason}")]
74 EncodingError {
75 reason: String,
77 },
78 #[error("io error: {0}")]
80 Io(#[from] std::io::Error),
81}
82
83impl From<CoreError> for ColumnarError {
84 fn from(err: CoreError) -> Self {
85 match err {
86 CoreError::ChecksumMismatch => ColumnarError::ChecksumMismatch,
87 CoreError::InvalidFormat(reason) => ColumnarError::InvalidFormat(reason),
88 CoreError::CorruptedSegment { segment_id, reason } => ColumnarError::CorruptedSegment {
89 reason: format!("segment {segment_id}: {reason}"),
90 },
91 CoreError::MemoryLimitExceeded { limit, requested } => {
92 ColumnarError::MemoryLimitExceeded { limit, requested }
93 }
94 CoreError::TxnConflict => ColumnarError::TxnConflict,
95 CoreError::NotFound => ColumnarError::NotFound,
96 CoreError::Io(e) => ColumnarError::Io(e),
97 other => ColumnarError::EncodingError {
98 reason: other.to_string(),
99 },
100 }
101 }
102}