1use std::io;
21use thiserror::Error;
22
23#[derive(Error, Debug)]
24pub enum SochDBError {
25 #[error("IO error: {0}")]
26 Io(#[from] io::Error),
27
28 #[error("Serialization error: {0}")]
29 Serialization(String),
30
31 #[error("Data corruption detected: {details}. Location: {location}. Recommendation: {hint}")]
32 DataCorruption {
33 details: String,
34 location: String,
35 hint: String,
36 },
37
38 #[error("Corruption detected: {0}")]
39 Corruption(String),
40
41 #[error("Key not found: {0}")]
42 NotFound(String),
43
44 #[error("Invalid argument: {0}")]
45 InvalidArgument(String),
46
47 #[error("Invalid timestamp in {field}: {value} is {reason}. Valid range: {min} to {max}")]
48 InvalidTimestampDetailed {
49 field: String,
50 value: u64,
51 reason: String,
52 min: u64,
53 max: u64,
54 },
55
56 #[error("Invalid timestamp: {0}")]
57 InvalidTimestamp(String),
58
59 #[error("Resource exhausted: {0}")]
60 ResourceExhausted(String),
61
62 #[error("Internal error: {0}")]
63 Internal(String),
64
65 #[error("Compaction error: {0}")]
66 Compaction(String),
67
68 #[error("Index error: {0}")]
69 Index(String),
70
71 #[error("Backup error: {0}")]
72 Backup(String),
73
74 #[error("Validation error: {0}")]
75 Validation(String),
76
77 #[error("Invalid data: {0}")]
78 InvalidData(String),
79
80 #[error("Invalid reference: {0}")]
81 InvalidReference(String),
82
83 #[error("Circuit breaker open: {0}")]
84 CircuitOpen(String),
85
86 #[error("Write stall timeout: {0}")]
87 WriteStall(String),
88
89 #[error("Schema evolution error: {0}")]
90 SchemaEvolution(String),
91
92 #[error("Lock error: {0}")]
93 LockError(String),
94
95 #[error("Database is locked by another process")]
96 DatabaseLocked,
97
98 #[error("WAL epoch mismatch: expected {expected}, got {actual}")]
99 EpochMismatch { expected: u64, actual: u64 },
100
101 #[error("Split-brain detected in WAL: {0}")]
102 SplitBrain(String),
103}
104
105pub type Result<T> = std::result::Result<T, SochDBError>;