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";
74pub const SERIALIZATION_FAILED: &str = "LDB-4001";
78pub const DESERIALIZATION_FAILED: &str = "LDB-4002";
80pub const JSON_PARSE_ERROR: &str = "LDB-4003";
82pub const BASE64_DECODE_ERROR: &str = "LDB-4004";
84pub const STATE_KEY_MISSING: &str = "LDB-4005";
86pub const STATE_CORRUPTION: &str = "LDB-4006";
88pub const CLUSTER_STATE_LIFECYCLE_UNSUPPORTED: &str = "LDB-4007";
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";
122pub const SOURCE_CHECKPOINT_REQUIRED: &str = "LDB-5034";
124pub const EXACTLY_ONCE_PROTOCOL_INCOMPLETE: &str = "LDB-5035";
126pub const DELIVERY_STATE_DURABILITY_MISMATCH: &str = "LDB-5036";
128pub const EXACTLY_ONCE_SOURCE_UNCERTIFIED: &str = "LDB-5037";
130
131pub const CHECKPOINT_FAILED: &str = "LDB-6001";
135pub const CHECKPOINT_NOT_FOUND: &str = "LDB-6002";
137pub const RECOVERY_FAILED: &str = "LDB-6003";
139pub const SINK_ROLLBACK_FAILED: &str = "LDB-6004";
141pub const WAL_ERROR: &str = "LDB-6005";
143pub const WAL_INVALID_LENGTH: &str = "LDB-6006";
145pub const WAL_CHECKSUM_MISMATCH: &str = "LDB-6007";
147pub const MANIFEST_PERSIST_FAILED: &str = "LDB-6008";
149pub const CHECKPOINT_PRUNE_FAILED: &str = "LDB-6009";
151pub const SIDECAR_CORRUPTION: &str = "LDB-6010";
153pub const OFFSET_METADATA_MISSING: &str = "LDB-6011";
155pub const DURABILITY_GATE_MISS: &str = "LDB-6020";
159pub const DURABILITY_GATE_ROLLBACK_FAILED: &str = "LDB-6021";
162pub const DURABILITY_GATE_BACKEND_ERROR: &str = "LDB-6022";
166pub const DURABILITY_GATE_ROLLBACK_ON_ERROR_FAILED: &str = "LDB-6023";
168
169pub const QUERY_EXECUTION_FAILED: &str = "LDB-7001";
175pub const ARROW_ERROR: &str = "LDB-7002";
177pub const PLAN_OPTIMIZATION_FAILED: &str = "LDB-7003";
179
180pub const INTERNAL: &str = "LDB-8001";
184pub const PIPELINE_ERROR: &str = "LDB-8002";
186pub const MATERIALIZED_VIEW_ERROR: &str = "LDB-8003";
188pub const QUERY_PIPELINE_ERROR: &str = "LDB-8004";
190pub const NO_COMPILED_PROJECTION: &str = "LDB-8050";
192
193#[derive(Debug, Clone, Copy, PartialEq, Eq)]
200#[repr(u16)]
201pub enum HotPathError {
202 LateEvent = 0x0001,
204 StateKeyMissing = 0x0002,
206 Backpressure = 0x0003,
208 SerializationOverflow = 0x0004,
210 SchemaMismatch = 0x0005,
212 AggregateStateCorruption = 0x0006,
214 QueueFull = 0x0007,
216 ChannelClosed = 0x0008,
218}
219
220impl HotPathError {
221 #[must_use]
223 pub const fn message(self) -> &'static str {
224 match self {
225 Self::LateEvent => "Event arrived after watermark; dropped",
226 Self::StateKeyMissing => "State key not found in store",
227 Self::Backpressure => "Downstream backpressure; event buffered",
228 Self::SerializationOverflow => "Serialization buffer capacity exceeded",
229 Self::SchemaMismatch => "Record batch schema does not match expected",
230 Self::AggregateStateCorruption => "Aggregate state checksum mismatch detected",
231 Self::QueueFull => "Queue is full; cannot push event",
232 Self::ChannelClosed => "Channel is closed or disconnected",
233 }
234 }
235
236 #[must_use]
238 pub const fn code(self) -> u16 {
239 self as u16
240 }
241
242 #[must_use]
244 pub const fn ldb_code(self) -> &'static str {
245 match self {
246 Self::LateEvent => LATE_DATA_REJECTED,
247 Self::StateKeyMissing => STATE_KEY_MISSING,
248 Self::Backpressure => "LDB-8010",
249 Self::SerializationOverflow => SERIALIZATION_FAILED,
250 Self::SchemaMismatch => SCHEMA_MISMATCH,
251 Self::AggregateStateCorruption => STATE_CORRUPTION,
252 Self::QueueFull => "LDB-8011",
253 Self::ChannelClosed => "LDB-8012",
254 }
255 }
256}
257
258impl std::fmt::Display for HotPathError {
259 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
260 write!(f, "[{}] {}", self.ldb_code(), self.message())
261 }
262}
263
264impl std::error::Error for HotPathError {}
265
266#[cfg(test)]
267mod tests {
268 use super::*;
269
270 #[test]
271 fn hot_path_error_is_copy_and_small() {
272 let e = HotPathError::LateEvent;
273 let e2 = e; assert_eq!(e, e2);
275 assert_eq!(std::mem::size_of::<HotPathError>(), 2);
276 }
277
278 #[test]
279 fn hot_path_error_codes_are_nonzero() {
280 let variants = [
281 HotPathError::LateEvent,
282 HotPathError::StateKeyMissing,
283 HotPathError::Backpressure,
284 HotPathError::SerializationOverflow,
285 HotPathError::SchemaMismatch,
286 HotPathError::AggregateStateCorruption,
287 HotPathError::QueueFull,
288 HotPathError::ChannelClosed,
289 ];
290 for v in &variants {
291 assert!(v.code() > 0, "{v:?} has zero code");
292 assert!(!v.message().is_empty(), "{v:?} has empty message");
293 assert!(
294 v.ldb_code().starts_with("LDB-"),
295 "{v:?} has bad ldb_code: {}",
296 v.ldb_code()
297 );
298 }
299 }
300
301 #[test]
302 fn hot_path_error_display() {
303 let e = HotPathError::LateEvent;
304 let s = e.to_string();
305 assert!(s.starts_with("[LDB-"));
306 assert!(s.contains("watermark"));
307 }
308
309 #[test]
310 fn error_codes_are_stable_strings() {
311 assert_eq!(INVALID_CONFIG, "LDB-0001");
312 assert_eq!(SERIALIZATION_FAILED, "LDB-4001");
313 assert_eq!(EXACTLY_ONCE_SOURCE_UNCERTIFIED, "LDB-5037");
314 assert_eq!(CHECKPOINT_FAILED, "LDB-6001");
315 assert_eq!(INTERNAL, "LDB-8001");
316 }
317}
318
319#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
321pub enum WarningSeverity {
322 Info,
324 Warning,
326 Error,
328}