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("unsupported compression: {algorithm}")]
25 UnsupportedCompression {
26 algorithm: String,
28 },
29 #[error("memory limit exceeded: limit={limit}, requested={requested}")]
31 MemoryLimitExceeded {
32 limit: usize,
34 requested: usize,
36 },
37 #[error("invalid format: {0}")]
39 InvalidFormat(String),
40 #[error("not found")]
42 NotFound,
43 #[error("transaction conflict")]
45 TxnConflict,
46 #[error("row group too large: size={size}, max={max}")]
48 RowGroupTooLarge {
49 size: u64,
51 max: u64,
53 },
54 #[error("not in in-memory mode")]
56 NotInMemoryMode,
57 #[error("table not found: {table}")]
59 TableNotFound {
60 table: String,
62 },
63 #[error("corrupted segment: {reason}")]
65 CorruptedSegment {
66 reason: String,
68 },
69 #[error("encoding error: {reason}")]
71 EncodingError {
72 reason: String,
74 },
75 #[error("io error: {0}")]
77 Io(#[from] std::io::Error),
78}
79
80impl From<CoreError> for ColumnarError {
81 fn from(err: CoreError) -> Self {
82 match err {
83 CoreError::ChecksumMismatch => ColumnarError::ChecksumMismatch,
84 CoreError::InvalidFormat(reason) => ColumnarError::InvalidFormat(reason),
85 CoreError::CorruptedSegment { reason } => ColumnarError::CorruptedSegment { reason },
86 CoreError::MemoryLimitExceeded { limit, requested } => {
87 ColumnarError::MemoryLimitExceeded { limit, requested }
88 }
89 CoreError::TxnConflict => ColumnarError::TxnConflict,
90 CoreError::NotFound => ColumnarError::NotFound,
91 CoreError::Io(e) => ColumnarError::Io(e),
92 other => ColumnarError::EncodingError {
93 reason: other.to_string(),
94 },
95 }
96 }
97}