oxirs_tdb/
error.rs

1//! Error types for OxiRS TDB storage engine
2
3use thiserror::Error;
4
5/// TDB error type
6#[derive(Error, Debug)]
7pub enum TdbError {
8    /// I/O error
9    #[error("I/O error: {0}")]
10    Io(#[from] std::io::Error),
11
12    /// Page not found
13    #[error("Page not found: {0}")]
14    PageNotFound(u64),
15
16    /// Buffer pool full
17    #[error("Buffer pool full, cannot evict any page")]
18    BufferPoolFull,
19
20    /// Invalid page size
21    #[error("Invalid page size: expected {expected}, got {got}")]
22    InvalidPageSize {
23        /// Expected page size
24        expected: usize,
25        /// Actual page size received
26        got: usize,
27    },
28
29    /// Transaction error
30    #[error("Transaction error: {0}")]
31    Transaction(String),
32
33    /// Deadlock detected
34    #[error("Deadlock detected for transaction {txn_id}")]
35    Deadlock {
36        /// Transaction ID that encountered deadlock
37        txn_id: u64,
38    },
39
40    /// Transaction not active
41    #[error("Transaction {txn_id} is not active")]
42    TransactionNotActive {
43        /// Transaction ID that is not active
44        txn_id: u64,
45    },
46
47    /// Invalid node ID
48    #[error("Invalid node ID: {0}")]
49    InvalidNodeId(u64),
50
51    /// Serialization error
52    #[error("Serialization error: {0}")]
53    Serialization(String),
54
55    /// Deserialization error
56    #[error("Deserialization error: {0}")]
57    Deserialization(String),
58
59    /// Node too large to fit in page
60    #[error("Node too large: {size} bytes exceeds maximum {max} bytes")]
61    NodeTooLarge {
62        /// Actual node size in bytes
63        size: usize,
64        /// Maximum allowed size in bytes
65        max: usize,
66    },
67
68    /// Index error
69    #[error("Index error: {0}")]
70    Index(String),
71
72    /// WAL error
73    #[error("WAL error: {0}")]
74    Wal(String),
75
76    /// Invalid input
77    #[error("Invalid input: {0}")]
78    InvalidInput(String),
79
80    /// Invalid configuration
81    #[error("Invalid configuration: {0}")]
82    InvalidConfiguration(String),
83
84    /// Unsupported feature or operation
85    #[error("Unsupported: {0}")]
86    Unsupported(String),
87
88    /// Generic error
89    #[error("{0}")]
90    Other(String),
91}
92
93/// Result type for TDB operations
94pub type Result<T> = std::result::Result<T, TdbError>;