laminar_core/mv/error.rs
1//! Error types for materialized view operations.
2
3use thiserror::Error;
4
5/// Errors that can occur during materialized view operations.
6#[derive(Debug, Error)]
7pub enum MvError {
8 /// Attempted to register a view with a name that already exists.
9 #[error("materialized view already exists: {0}")]
10 DuplicateName(String),
11
12 /// A source referenced by the view does not exist.
13 #[error("source not found: {0}")]
14 SourceNotFound(String),
15
16 /// Registration would create a dependency cycle.
17 #[error("dependency cycle detected involving: {0}")]
18 CycleDetected(String),
19
20 /// The materialized view was not found.
21 #[error("materialized view not found: {0}")]
22 ViewNotFound(String),
23
24 /// The operator for a view was not found.
25 #[error("operator not found for view: {0}")]
26 OperatorNotFound(String),
27
28 /// Cannot drop view because other views depend on it.
29 #[error("cannot drop view '{0}': dependent views exist: {1:?}")]
30 HasDependents(String, Vec<String>),
31
32 /// Operator error during processing.
33 #[error("operator error: {0}")]
34 OperatorError(#[from] crate::operator::OperatorError),
35
36 /// State serialization/deserialization error.
37 #[error("serialization error: {0}")]
38 SerializationError(String),
39
40 /// View is in an invalid state for the requested operation.
41 #[error("view '{0}' is in invalid state: {1:?}")]
42 InvalidState(String, MvState),
43
44 /// Watermark propagation error.
45 #[error("watermark propagation error: {0}")]
46 WatermarkError(String),
47}
48
49/// Materialized view execution state.
50///
51/// Production currently only distinguishes `Running` from `Dropping`;
52/// the `Paused` and `Error` variants existed for a planned lifecycle
53/// transition that was never wired to operator failure events. Re-add
54/// them when the registry actually transitions on those signals.
55#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
56pub enum MvState {
57 /// View is actively processing events.
58 #[default]
59 Running,
60 /// View is being dropped.
61 Dropping,
62}