Skip to main content

panproto_lens/
edit_error.rs

1//! Error types for edit lens operations.
2
3/// Errors from edit lens translation.
4#[derive(Debug, thiserror::Error)]
5#[non_exhaustive]
6pub enum EditLensError {
7    /// An edit could not be translated through the lens.
8    #[error("translation failed: {0}")]
9    TranslationFailed(String),
10
11    /// A complement policy conflict was encountered.
12    #[error("policy conflict for kind {kind}: {detail}")]
13    PolicyConflict {
14        /// The vertex kind involved.
15        kind: String,
16        /// Description of the conflict.
17        detail: String,
18    },
19
20    /// A directed equation has no inverse, but one was needed for `put_edit`.
21    #[error("no inverse for directed equation: {rule_name}")]
22    NoInverse {
23        /// The name of the directed equation.
24        rule_name: String,
25    },
26
27    /// The complement state is inconsistent with the current edit.
28    #[error("complement inconsistent: {0}")]
29    ComplementInconsistent(String),
30
31    /// Delegation to the restrict pipeline failed.
32    #[error("restrict error: {0}")]
33    Restrict(#[from] panproto_inst::RestrictError),
34
35    /// An edit could not be applied to the instance.
36    #[error("edit apply error: {0}")]
37    EditApply(#[from] panproto_inst::EditError),
38
39    /// A refinement constraint on the target schema was violated.
40    #[error(
41        "refinement violation on vertex {vertex}: constraint {constraint_sort}({constraint_value}) failed"
42    )]
43    RefinementViolation {
44        /// The target vertex whose constraint was violated.
45        vertex: String,
46        /// The constraint sort (e.g., `"maxLength"`).
47        constraint_sort: String,
48        /// The constraint value (e.g., `"3000"`).
49        constraint_value: String,
50        /// Description of why the constraint failed.
51        detail: String,
52    },
53}