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