laminar_core/
error_codes.rs1pub const INVALID_CONFIG: &str = "LDB-0001";
29pub const MISSING_CONFIG: &str = "LDB-0002";
31pub const UNRESOLVED_CONFIG_VAR: &str = "LDB-0003";
33pub const SHUTDOWN: &str = "LDB-0004";
35pub const INVALID_OPERATION: &str = "LDB-0005";
37pub const SCHEMA_MISMATCH: &str = "LDB-0006";
39
40pub const SQL_UNSUPPORTED: &str = "LDB-1001";
44pub const SQL_PLANNING_FAILED: &str = "LDB-1002";
46pub const SQL_COLUMN_NOT_FOUND: &str = "LDB-1100";
48pub const SQL_TABLE_NOT_FOUND: &str = "LDB-1101";
50pub const SQL_TYPE_MISMATCH: &str = "LDB-1200";
52
53pub const WATERMARK_REQUIRED: &str = "LDB-2001";
57pub const WINDOW_INVALID: &str = "LDB-2002";
59pub const WINDOW_SIZE_INVALID: &str = "LDB-2003";
61pub const LATE_DATA_REJECTED: &str = "LDB-2004";
63
64pub const JOIN_KEY_MISSING: &str = "LDB-3001";
68pub const JOIN_TIME_BOUND_MISSING: &str = "LDB-3002";
70pub const TEMPORAL_JOIN_NO_PK: &str = "LDB-3003";
72pub const JOIN_TYPE_UNSUPPORTED: &str = "LDB-3004";
74
75pub const SERIALIZATION_FAILED: &str = "LDB-4001";
79pub const DESERIALIZATION_FAILED: &str = "LDB-4002";
81pub const JSON_PARSE_ERROR: &str = "LDB-4003";
83pub const BASE64_DECODE_ERROR: &str = "LDB-4004";
85pub const STATE_KEY_MISSING: &str = "LDB-4005";
87pub const STATE_CORRUPTION: &str = "LDB-4006";
89
90pub const CONNECTOR_CONNECTION_FAILED: &str = "LDB-5001";
94pub const CONNECTOR_AUTH_FAILED: &str = "LDB-5002";
96pub const CONNECTOR_READ_ERROR: &str = "LDB-5003";
98pub const CONNECTOR_WRITE_ERROR: &str = "LDB-5004";
100pub const CONNECTOR_CONFIG_ERROR: &str = "LDB-5005";
102pub const SOURCE_NOT_FOUND: &str = "LDB-5010";
104pub const SINK_NOT_FOUND: &str = "LDB-5011";
106pub const SOURCE_ALREADY_EXISTS: &str = "LDB-5012";
108pub const SINK_ALREADY_EXISTS: &str = "LDB-5013";
110pub const CONNECTOR_SERDE_ERROR: &str = "LDB-5020";
112pub const CONNECTOR_SCHEMA_ERROR: &str = "LDB-5021";
114pub const EXACTLY_ONCE_NON_REPLAYABLE: &str = "LDB-5030";
116pub const EXACTLY_ONCE_SINK_UNSUPPORTED: &str = "LDB-5031";
118pub const EXACTLY_ONCE_NO_CHECKPOINT: &str = "LDB-5032";
120pub const MIXED_DELIVERY_CAPABILITIES: &str = "LDB-5033";
122
123pub const CHECKPOINT_FAILED: &str = "LDB-6001";
127pub const CHECKPOINT_NOT_FOUND: &str = "LDB-6002";
129pub const RECOVERY_FAILED: &str = "LDB-6003";
131pub const SINK_ROLLBACK_FAILED: &str = "LDB-6004";
133pub const WAL_ERROR: &str = "LDB-6005";
135pub const WAL_INVALID_LENGTH: &str = "LDB-6006";
137pub const WAL_CHECKSUM_MISMATCH: &str = "LDB-6007";
139pub const MANIFEST_PERSIST_FAILED: &str = "LDB-6008";
141pub const CHECKPOINT_PRUNE_FAILED: &str = "LDB-6009";
143pub const SIDECAR_CORRUPTION: &str = "LDB-6010";
145pub const OFFSET_METADATA_MISSING: &str = "LDB-6011";
147pub const DURABILITY_GATE_MISS: &str = "LDB-6020";
151pub const DURABILITY_GATE_ROLLBACK_FAILED: &str = "LDB-6021";
154pub const DURABILITY_GATE_BACKEND_ERROR: &str = "LDB-6022";
158pub const DURABILITY_GATE_ROLLBACK_ON_ERROR_FAILED: &str = "LDB-6023";
160
161pub const QUERY_EXECUTION_FAILED: &str = "LDB-7001";
167pub const ARROW_ERROR: &str = "LDB-7002";
169pub const PLAN_OPTIMIZATION_FAILED: &str = "LDB-7003";
171
172pub const INTERNAL: &str = "LDB-8001";
176pub const PIPELINE_ERROR: &str = "LDB-8002";
178pub const MATERIALIZED_VIEW_ERROR: &str = "LDB-8003";
180pub const QUERY_PIPELINE_ERROR: &str = "LDB-8004";
182pub const NO_COMPILED_PROJECTION: &str = "LDB-8050";
184
185#[derive(Debug, Clone, Copy, PartialEq, Eq)]
192#[repr(u16)]
193pub enum HotPathError {
194 LateEvent = 0x0001,
196 StateKeyMissing = 0x0002,
198 Backpressure = 0x0003,
200 SerializationOverflow = 0x0004,
202 SchemaMismatch = 0x0005,
204 AggregateStateCorruption = 0x0006,
206 QueueFull = 0x0007,
208 ChannelClosed = 0x0008,
210}
211
212impl HotPathError {
213 #[must_use]
215 pub const fn message(self) -> &'static str {
216 match self {
217 Self::LateEvent => "Event arrived after watermark; dropped",
218 Self::StateKeyMissing => "State key not found in store",
219 Self::Backpressure => "Downstream backpressure; event buffered",
220 Self::SerializationOverflow => "Serialization buffer capacity exceeded",
221 Self::SchemaMismatch => "Record batch schema does not match expected",
222 Self::AggregateStateCorruption => "Aggregate state checksum mismatch detected",
223 Self::QueueFull => "Queue is full; cannot push event",
224 Self::ChannelClosed => "Channel is closed or disconnected",
225 }
226 }
227
228 #[must_use]
230 pub const fn code(self) -> u16 {
231 self as u16
232 }
233
234 #[must_use]
236 pub const fn ldb_code(self) -> &'static str {
237 match self {
238 Self::LateEvent => LATE_DATA_REJECTED,
239 Self::StateKeyMissing => STATE_KEY_MISSING,
240 Self::Backpressure => "LDB-8010",
241 Self::SerializationOverflow => SERIALIZATION_FAILED,
242 Self::SchemaMismatch => SCHEMA_MISMATCH,
243 Self::AggregateStateCorruption => STATE_CORRUPTION,
244 Self::QueueFull => "LDB-8011",
245 Self::ChannelClosed => "LDB-8012",
246 }
247 }
248}
249
250impl std::fmt::Display for HotPathError {
251 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
252 write!(f, "[{}] {}", self.ldb_code(), self.message())
253 }
254}
255
256impl std::error::Error for HotPathError {}
257
258#[cfg(test)]
259mod tests {
260 use super::*;
261
262 #[test]
263 fn hot_path_error_is_copy_and_small() {
264 let e = HotPathError::LateEvent;
265 let e2 = e; assert_eq!(e, e2);
267 assert_eq!(std::mem::size_of::<HotPathError>(), 2);
268 }
269
270 #[test]
271 fn hot_path_error_codes_are_nonzero() {
272 let variants = [
273 HotPathError::LateEvent,
274 HotPathError::StateKeyMissing,
275 HotPathError::Backpressure,
276 HotPathError::SerializationOverflow,
277 HotPathError::SchemaMismatch,
278 HotPathError::AggregateStateCorruption,
279 HotPathError::QueueFull,
280 HotPathError::ChannelClosed,
281 ];
282 for v in &variants {
283 assert!(v.code() > 0, "{v:?} has zero code");
284 assert!(!v.message().is_empty(), "{v:?} has empty message");
285 assert!(
286 v.ldb_code().starts_with("LDB-"),
287 "{v:?} has bad ldb_code: {}",
288 v.ldb_code()
289 );
290 }
291 }
292
293 #[test]
294 fn hot_path_error_display() {
295 let e = HotPathError::LateEvent;
296 let s = e.to_string();
297 assert!(s.starts_with("[LDB-"));
298 assert!(s.contains("watermark"));
299 }
300
301 #[test]
302 fn error_codes_are_stable_strings() {
303 assert_eq!(INVALID_CONFIG, "LDB-0001");
304 assert_eq!(SERIALIZATION_FAILED, "LDB-4001");
305 assert_eq!(CHECKPOINT_FAILED, "LDB-6001");
306 assert_eq!(INTERNAL, "LDB-8001");
307 }
308}
309
310#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
312pub enum WarningSeverity {
313 Info,
315 Warning,
317 Error,
319}