yeti_types/error/
domain.rs1use std::io;
9
10#[derive(Debug, thiserror::Error)]
12pub enum StorageError {
13 #[error("Key not found: {0}")]
15 KeyNotFound(String),
16
17 #[error("Write conflict for key: {0}")]
19 WriteConflict(String),
20
21 #[error("Corruption detected: {0}")]
23 Corruption(String),
24
25 #[error("I/O error: {0}")]
27 Io(#[from] io::Error),
28
29 #[error("RocksDB error: {0}")]
31 RocksDb(String),
32
33 #[error("Failed to initialize storage: {0}")]
35 InitializationFailed(String),
36
37 #[error("WAL error: {0}")]
39 Wal(String),
40}
41
42#[derive(Debug, Clone, thiserror::Error)]
44pub enum QueryError {
45 #[error("Failed to parse FIQL query: {0}")]
47 ParseError(String),
48
49 #[error("Invalid select field: {0}")]
51 InvalidSelectField(String),
52
53 #[error("Invalid sort parameter: {0}")]
55 InvalidSort(String),
56
57 #[error("Invalid pagination: {0}")]
59 InvalidPagination(String),
60
61 #[error("Query too complex: {reason}")]
63 TooComplex {
64 reason: String,
66 },
67}
68
69#[derive(Debug, Clone, thiserror::Error)]
71pub enum SchemaError {
72 #[error("Failed to parse GraphQL schema: {0}")]
74 ParseError(String),
75
76 #[error("Table definition not found: {0}")]
78 TableNotFound(String),
79
80 #[error("Field definition not found: {table}.{field}")]
82 FieldNotFound {
83 table: String,
85 field: String,
87 },
88
89 #[error("Invalid type definition: {0}")]
91 InvalidType(String),
92
93 #[error("Invalid directive: {0}")]
95 InvalidDirective(String),
96
97 #[error("Failed to read schema file: {0}")]
99 FileError(String),
100
101 #[error("Duplicate definition: {0}")]
103 Duplicate(String),
104}
105
106impl From<io::Error> for SchemaError {
107 fn from(err: io::Error) -> Self {
108 Self::FileError(err.to_string())
109 }
110}
111
112#[derive(Debug, Clone, thiserror::Error)]
114pub enum EncodingError {
115 #[error("JSON serialization error: {0}")]
117 Json(String),
118
119 #[error("Key encoding error: {0}")]
121 KeyEncoding(String),
122
123 #[error("Value encoding error: {0}")]
125 ValueEncoding(String),
126
127 #[error("UTF-8 decoding error: {0}")]
129 Utf8(String),
130
131 #[error("Invalid binary format: {0}")]
133 InvalidFormat(String),
134
135 #[error("MessagePack error: {0}")]
137 MessagePack(String),
138
139 #[error("Invalid data: {0}")]
141 InvalidData(String),
142
143 #[error("Invalid type: {0}")]
145 InvalidType(String),
146
147 #[error("Unsupported type: {0}")]
149 UnsupportedType(String),
150}
151
152impl From<serde_json::Error> for EncodingError {
153 fn from(err: serde_json::Error) -> Self {
154 Self::Json(err.to_string())
155 }
156}
157
158impl From<std::str::Utf8Error> for EncodingError {
159 fn from(err: std::str::Utf8Error) -> Self {
160 Self::Utf8(err.to_string())
161 }
162}
163
164#[derive(Debug, Clone, thiserror::Error)]
166pub enum BackendError {
167 #[error("Backend not available: {backend_type}")]
169 NotAvailable {
170 backend_type: String,
172 },
173
174 #[error("Failed to initialize backend '{backend_type}': {reason}")]
176 InitializationFailed {
177 backend_type: String,
179 reason: String,
181 },
182
183 #[error("Backend configuration error: {0}")]
185 ConfigError(String),
186
187 #[error("No backend mapping found for table: {0}")]
189 MappingNotFound(String),
190}
191
192#[derive(Debug, Clone, thiserror::Error)]
194pub enum IndexError {
195 #[error("Index not found: {table}.{attribute}")]
197 NotFound {
198 table: String,
200 attribute: String,
202 },
203
204 #[error("Index corruption detected: {0}")]
206 Corruption(String),
207
208 #[error("Failed to update index: {0}")]
210 UpdateFailed(String),
211
212 #[error("Index scan error: {0}")]
214 ScanError(String),
215}
216
217impl Clone for StorageError {
219 fn clone(&self) -> Self {
220 match self {
221 Self::KeyNotFound(s) => Self::KeyNotFound(s.clone()),
222 Self::WriteConflict(s) => Self::WriteConflict(s.clone()),
223 Self::Corruption(s) => Self::Corruption(s.clone()),
224 Self::Io(e) => Self::Io(io::Error::new(e.kind(), e.to_string())),
225 Self::RocksDb(s) => Self::RocksDb(s.clone()),
226 Self::InitializationFailed(s) => Self::InitializationFailed(s.clone()),
227 Self::Wal(s) => Self::Wal(s.clone()),
228 }
229 }
230}