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";
147
148pub const QUERY_EXECUTION_FAILED: &str = "LDB-7001";
154pub const ARROW_ERROR: &str = "LDB-7002";
156pub const PLAN_OPTIMIZATION_FAILED: &str = "LDB-7003";
158
159pub const INTERNAL: &str = "LDB-8001";
163pub const PIPELINE_ERROR: &str = "LDB-8002";
165pub const MATERIALIZED_VIEW_ERROR: &str = "LDB-8003";
167pub const QUERY_PIPELINE_ERROR: &str = "LDB-8004";
169pub const NO_COMPILED_PROJECTION: &str = "LDB-8050";
171
172#[derive(Debug, Clone, Copy, PartialEq, Eq)]
179#[repr(u16)]
180pub enum HotPathError {
181 LateEvent = 0x0001,
183 StateKeyMissing = 0x0002,
185 Backpressure = 0x0003,
187 SerializationOverflow = 0x0004,
189 SchemaMismatch = 0x0005,
191 AggregateStateCorruption = 0x0006,
193 QueueFull = 0x0007,
195 ChannelClosed = 0x0008,
197}
198
199impl HotPathError {
200 #[must_use]
202 pub const fn message(self) -> &'static str {
203 match self {
204 Self::LateEvent => "Event arrived after watermark; dropped",
205 Self::StateKeyMissing => "State key not found in store",
206 Self::Backpressure => "Downstream backpressure; event buffered",
207 Self::SerializationOverflow => "Serialization buffer capacity exceeded",
208 Self::SchemaMismatch => "Record batch schema does not match expected",
209 Self::AggregateStateCorruption => "Aggregate state checksum mismatch detected",
210 Self::QueueFull => "Queue is full; cannot push event",
211 Self::ChannelClosed => "Channel is closed or disconnected",
212 }
213 }
214
215 #[must_use]
217 pub const fn code(self) -> u16 {
218 self as u16
219 }
220
221 #[must_use]
223 pub const fn ldb_code(self) -> &'static str {
224 match self {
225 Self::LateEvent => LATE_DATA_REJECTED,
226 Self::StateKeyMissing => STATE_KEY_MISSING,
227 Self::Backpressure => "LDB-8010",
228 Self::SerializationOverflow => SERIALIZATION_FAILED,
229 Self::SchemaMismatch => SCHEMA_MISMATCH,
230 Self::AggregateStateCorruption => STATE_CORRUPTION,
231 Self::QueueFull => "LDB-8011",
232 Self::ChannelClosed => "LDB-8012",
233 }
234 }
235}
236
237impl std::fmt::Display for HotPathError {
238 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
239 write!(f, "[{}] {}", self.ldb_code(), self.message())
240 }
241}
242
243impl std::error::Error for HotPathError {}
244
245#[cfg(test)]
246mod tests {
247 use super::*;
248
249 #[test]
250 fn hot_path_error_is_copy_and_small() {
251 let e = HotPathError::LateEvent;
252 let e2 = e; assert_eq!(e, e2);
254 assert_eq!(std::mem::size_of::<HotPathError>(), 2);
255 }
256
257 #[test]
258 fn hot_path_error_codes_are_nonzero() {
259 let variants = [
260 HotPathError::LateEvent,
261 HotPathError::StateKeyMissing,
262 HotPathError::Backpressure,
263 HotPathError::SerializationOverflow,
264 HotPathError::SchemaMismatch,
265 HotPathError::AggregateStateCorruption,
266 HotPathError::QueueFull,
267 HotPathError::ChannelClosed,
268 ];
269 for v in &variants {
270 assert!(v.code() > 0, "{v:?} has zero code");
271 assert!(!v.message().is_empty(), "{v:?} has empty message");
272 assert!(
273 v.ldb_code().starts_with("LDB-"),
274 "{v:?} has bad ldb_code: {}",
275 v.ldb_code()
276 );
277 }
278 }
279
280 #[test]
281 fn hot_path_error_display() {
282 let e = HotPathError::LateEvent;
283 let s = e.to_string();
284 assert!(s.starts_with("[LDB-"));
285 assert!(s.contains("watermark"));
286 }
287
288 #[test]
289 fn error_codes_are_stable_strings() {
290 assert_eq!(INVALID_CONFIG, "LDB-0001");
291 assert_eq!(SERIALIZATION_FAILED, "LDB-4001");
292 assert_eq!(CHECKPOINT_FAILED, "LDB-6001");
293 assert_eq!(INTERNAL, "LDB-8001");
294 }
295}
296
297#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
299pub enum WarningSeverity {
300 Info,
302 Warning,
304 Error,
306}