laminar_core/
error_codes.rs1pub const INVALID_CONFIG: &str = "LDB-0001";
30pub const MISSING_CONFIG: &str = "LDB-0002";
32pub const UNRESOLVED_CONFIG_VAR: &str = "LDB-0003";
34pub const SHUTDOWN: &str = "LDB-0004";
36pub const INVALID_OPERATION: &str = "LDB-0005";
38pub const SCHEMA_MISMATCH: &str = "LDB-0006";
40
41pub const SQL_UNSUPPORTED: &str = "LDB-1001";
47pub const SQL_PLANNING_FAILED: &str = "LDB-1002";
49pub const SQL_COLUMN_NOT_FOUND: &str = "LDB-1100";
51pub const SQL_TABLE_NOT_FOUND: &str = "LDB-1101";
53pub const SQL_TYPE_MISMATCH: &str = "LDB-1200";
55
56pub const WATERMARK_REQUIRED: &str = "LDB-2001";
60pub const WINDOW_INVALID: &str = "LDB-2002";
62pub const WINDOW_SIZE_INVALID: &str = "LDB-2003";
64pub const LATE_DATA_REJECTED: &str = "LDB-2004";
66
67pub const JOIN_KEY_MISSING: &str = "LDB-3001";
71pub const JOIN_TIME_BOUND_MISSING: &str = "LDB-3002";
73pub const TEMPORAL_JOIN_NO_PK: &str = "LDB-3003";
75pub const JOIN_TYPE_UNSUPPORTED: &str = "LDB-3004";
77
78pub const SERIALIZATION_FAILED: &str = "LDB-4001";
82pub const DESERIALIZATION_FAILED: &str = "LDB-4002";
84pub const JSON_PARSE_ERROR: &str = "LDB-4003";
86pub const BASE64_DECODE_ERROR: &str = "LDB-4004";
88pub const STATE_KEY_MISSING: &str = "LDB-4005";
90pub const STATE_CORRUPTION: &str = "LDB-4006";
92
93pub const CONNECTOR_CONNECTION_FAILED: &str = "LDB-5001";
97pub const CONNECTOR_AUTH_FAILED: &str = "LDB-5002";
99pub const CONNECTOR_READ_ERROR: &str = "LDB-5003";
101pub const CONNECTOR_WRITE_ERROR: &str = "LDB-5004";
103pub const CONNECTOR_CONFIG_ERROR: &str = "LDB-5005";
105pub const SOURCE_NOT_FOUND: &str = "LDB-5010";
107pub const SINK_NOT_FOUND: &str = "LDB-5011";
109pub const SOURCE_ALREADY_EXISTS: &str = "LDB-5012";
111pub const SINK_ALREADY_EXISTS: &str = "LDB-5013";
113pub const CONNECTOR_SERDE_ERROR: &str = "LDB-5020";
115pub const CONNECTOR_SCHEMA_ERROR: &str = "LDB-5021";
117pub const EXACTLY_ONCE_NON_REPLAYABLE: &str = "LDB-5030";
119pub const EXACTLY_ONCE_SINK_UNSUPPORTED: &str = "LDB-5031";
121pub const EXACTLY_ONCE_NO_CHECKPOINT: &str = "LDB-5032";
123pub const MIXED_DELIVERY_CAPABILITIES: &str = "LDB-5033";
125
126pub const CHECKPOINT_FAILED: &str = "LDB-6001";
130pub const CHECKPOINT_NOT_FOUND: &str = "LDB-6002";
132pub const RECOVERY_FAILED: &str = "LDB-6003";
134pub const SINK_ROLLBACK_FAILED: &str = "LDB-6004";
136pub const WAL_ERROR: &str = "LDB-6005";
138pub const WAL_INVALID_LENGTH: &str = "LDB-6006";
140pub const WAL_CHECKSUM_MISMATCH: &str = "LDB-6007";
142pub const MANIFEST_PERSIST_FAILED: &str = "LDB-6008";
144pub const CHECKPOINT_PRUNE_FAILED: &str = "LDB-6009";
146pub const SIDECAR_CORRUPTION: &str = "LDB-6010";
148pub const OFFSET_METADATA_MISSING: &str = "LDB-6011";
150
151pub const QUERY_EXECUTION_FAILED: &str = "LDB-7001";
157pub const ARROW_ERROR: &str = "LDB-7002";
159pub const PLAN_OPTIMIZATION_FAILED: &str = "LDB-7003";
161
162pub const INTERNAL: &str = "LDB-8001";
166pub const PIPELINE_ERROR: &str = "LDB-8002";
168pub const MATERIALIZED_VIEW_ERROR: &str = "LDB-8003";
170pub const QUERY_PIPELINE_ERROR: &str = "LDB-8004";
172
173#[derive(Debug, Clone, Copy, PartialEq, Eq)]
180#[repr(u16)]
181pub enum HotPathError {
182 LateEvent = 0x0001,
184 StateKeyMissing = 0x0002,
186 Backpressure = 0x0003,
188 SerializationOverflow = 0x0004,
190 SchemaMismatch = 0x0005,
192 AggregateStateCorruption = 0x0006,
194 QueueFull = 0x0007,
196 ChannelClosed = 0x0008,
198}
199
200impl HotPathError {
201 #[must_use]
203 pub const fn message(self) -> &'static str {
204 match self {
205 Self::LateEvent => "Event arrived after watermark; dropped",
206 Self::StateKeyMissing => "State key not found in store",
207 Self::Backpressure => "Downstream backpressure; event buffered",
208 Self::SerializationOverflow => "Serialization buffer capacity exceeded",
209 Self::SchemaMismatch => "Record batch schema does not match expected",
210 Self::AggregateStateCorruption => "Aggregate state checksum mismatch detected",
211 Self::QueueFull => "Queue is full; cannot push event",
212 Self::ChannelClosed => "Channel is closed or disconnected",
213 }
214 }
215
216 #[must_use]
218 pub const fn code(self) -> u16 {
219 self as u16
220 }
221
222 #[must_use]
224 pub const fn ldb_code(self) -> &'static str {
225 match self {
226 Self::LateEvent => LATE_DATA_REJECTED,
227 Self::StateKeyMissing => STATE_KEY_MISSING,
228 Self::Backpressure => "LDB-8010",
229 Self::SerializationOverflow => SERIALIZATION_FAILED,
230 Self::SchemaMismatch => SCHEMA_MISMATCH,
231 Self::AggregateStateCorruption => STATE_CORRUPTION,
232 Self::QueueFull => "LDB-8011",
233 Self::ChannelClosed => "LDB-8012",
234 }
235 }
236}
237
238impl std::fmt::Display for HotPathError {
239 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
240 write!(f, "[{}] {}", self.ldb_code(), self.message())
241 }
242}
243
244impl std::error::Error for HotPathError {}
245
246#[cfg(test)]
247mod tests {
248 use super::*;
249
250 #[test]
251 fn hot_path_error_is_copy_and_small() {
252 let e = HotPathError::LateEvent;
253 let e2 = e; assert_eq!(e, e2);
255 assert_eq!(std::mem::size_of::<HotPathError>(), 2);
256 }
257
258 #[test]
259 fn hot_path_error_codes_are_nonzero() {
260 let variants = [
261 HotPathError::LateEvent,
262 HotPathError::StateKeyMissing,
263 HotPathError::Backpressure,
264 HotPathError::SerializationOverflow,
265 HotPathError::SchemaMismatch,
266 HotPathError::AggregateStateCorruption,
267 HotPathError::QueueFull,
268 HotPathError::ChannelClosed,
269 ];
270 for v in &variants {
271 assert!(v.code() > 0, "{v:?} has zero code");
272 assert!(!v.message().is_empty(), "{v:?} has empty message");
273 assert!(
274 v.ldb_code().starts_with("LDB-"),
275 "{v:?} has bad ldb_code: {}",
276 v.ldb_code()
277 );
278 }
279 }
280
281 #[test]
282 fn hot_path_error_display() {
283 let e = HotPathError::LateEvent;
284 let s = e.to_string();
285 assert!(s.starts_with("[LDB-"));
286 assert!(s.contains("watermark"));
287 }
288
289 #[test]
290 fn error_codes_are_stable_strings() {
291 assert_eq!(INVALID_CONFIG, "LDB-0001");
292 assert_eq!(SERIALIZATION_FAILED, "LDB-4001");
293 assert_eq!(CHECKPOINT_FAILED, "LDB-6001");
294 assert_eq!(INTERNAL, "LDB-8001");
295 }
296}