1use thiserror::Error;
4
5#[derive(Error, Debug)]
7pub enum TdbError {
8 #[error("I/O error: {0}")]
10 Io(#[from] std::io::Error),
11
12 #[error("Page not found: {0}")]
14 PageNotFound(u64),
15
16 #[error("Buffer pool full, cannot evict any page")]
18 BufferPoolFull,
19
20 #[error("Invalid page size: expected {expected}, got {got}")]
22 InvalidPageSize {
23 expected: usize,
25 got: usize,
27 },
28
29 #[error("Transaction error: {0}")]
31 Transaction(String),
32
33 #[error("Deadlock detected for transaction {txn_id}")]
35 Deadlock {
36 txn_id: u64,
38 },
39
40 #[error("Transaction {txn_id} is not active")]
42 TransactionNotActive {
43 txn_id: u64,
45 },
46
47 #[error("Invalid node ID: {0}")]
49 InvalidNodeId(u64),
50
51 #[error("Serialization error: {0}")]
53 Serialization(String),
54
55 #[error("Deserialization error: {0}")]
57 Deserialization(String),
58
59 #[error("Node too large: {size} bytes exceeds maximum {max} bytes")]
61 NodeTooLarge {
62 size: usize,
64 max: usize,
66 },
67
68 #[error("Index error: {0}")]
70 Index(String),
71
72 #[error("WAL error: {0}")]
74 Wal(String),
75
76 #[error("Invalid input: {0}")]
78 InvalidInput(String),
79
80 #[error("Invalid configuration: {0}")]
82 InvalidConfiguration(String),
83
84 #[error("Unsupported: {0}")]
86 Unsupported(String),
87
88 #[error("{0}")]
90 Other(String),
91}
92
93pub type Result<T> = std::result::Result<T, TdbError>;