1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum LanceError {
5 #[error("I/O error: {0}")]
6 Io(#[from] std::io::Error),
7
8 #[error("Buffer pool exhausted - no free batches available")]
9 BufferPoolExhausted,
10
11 #[error("Buffer too small: required {required} bytes, available {available}")]
12 BufferTooSmall { required: usize, available: usize },
13
14 #[error("Invalid TLV header: {0}")]
15 InvalidTlvHeader(String),
16
17 #[error("Invalid magic bytes - expected LANC")]
18 InvalidMagic,
19
20 #[error("CRC mismatch: expected {expected:#x}, got {actual:#x}")]
21 CrcMismatch { expected: u32, actual: u32 },
22
23 #[error("Unsupported kernel feature: {0}")]
24 UnsupportedKernel(&'static str),
25
26 #[error("Thread pinning failed for core {0}")]
27 PinFailed(usize),
28
29 #[error("NUMA allocation failed for node {0}")]
30 NumaAllocFailed(usize),
31
32 #[error("Memory lock (mlock) failed: {0}")]
33 MlockFailed(String),
34
35 #[error("Segment corrupted at offset {offset}: {reason}")]
36 SegmentCorrupted { offset: u64, reason: String },
37
38 #[error("Drain timeout exceeded")]
39 DrainTimeout,
40
41 #[error("Quorum not reached - required {required} ACKs, got {received}")]
42 QuorumNotReached { required: usize, received: usize },
43
44 #[error("Channel disconnected: {0}")]
45 ChannelDisconnected(&'static str),
46
47 #[error("Protocol error: {0}")]
48 Protocol(String),
49
50 #[error("Configuration error: {0}")]
51 Config(String),
52
53 #[error("Index out of bounds: {0}")]
54 IndexOutOfBounds(String),
55
56 #[error("WAL replay failed: {0}")]
57 WalReplayFailed(String),
58
59 #[error("Segment not found: {0}")]
60 SegmentNotFound(String),
61
62 #[error("Payload too large: {0} bytes exceeds maximum")]
63 PayloadTooLarge(usize),
64
65 #[error("Invalid data: {0}")]
66 InvalidData(String),
67
68 #[error("Fenced off: attempted token {attempted:?}, current {current:?}")]
69 FencedOff { attempted: u64, current: u64 },
70
71 #[error("Not found: {0}")]
72 NotFound(String),
73
74 #[error("Data corruption: {0}")]
75 DataCorruption(String),
76
77 #[error("Client error: {0}")]
78 Client(String),
79
80 #[error("Internal error: {0}")]
81 Internal(String),
82}
83
84pub type Result<T> = std::result::Result<T, LanceError>;