panproto_inst/edit_error.rs
1//! Error types for edit operations on instances.
2
3/// Errors from applying edits to instances.
4#[derive(Debug, thiserror::Error)]
5#[non_exhaustive]
6pub enum EditError {
7 /// A node ID was referenced but not found in the instance.
8 #[error("node not found: {0}")]
9 NodeNotFound(u32),
10
11 /// The node's anchor does not match what the edit expected.
12 #[error("anchor mismatch at node {node_id}: expected {expected}, got {actual}")]
13 AnchorMismatch {
14 /// The node ID.
15 node_id: u32,
16 /// The expected anchor.
17 expected: String,
18 /// The actual anchor.
19 actual: String,
20 },
21
22 /// A fan (hyper-edge instance) was not found.
23 #[error("fan not found for hyper-edge: {0}")]
24 FanNotFound(String),
25
26 /// General edit application failure.
27 #[error("edit apply failed: {0}")]
28 ApplyFailed(String),
29
30 /// A field transform failed during edit application.
31 #[error("field transform failed: {0}")]
32 FieldTransformFailed(String),
33
34 /// A table was not found in a functor instance.
35 #[error("table not found: {0}")]
36 TableNotFound(String),
37
38 /// A row was not found in a functor instance table.
39 #[error("row not found in table {table}: key {key}")]
40 RowNotFound {
41 /// The table name.
42 table: String,
43 /// The row key that was not found.
44 key: String,
45 },
46
47 /// The edit would create a cycle in a tree-shaped instance.
48 #[error("cycle detected: moving node {node_id} under {new_parent} would create a cycle")]
49 CycleDetected {
50 /// The node being moved.
51 node_id: u32,
52 /// The proposed new parent.
53 new_parent: u32,
54 },
55
56 /// The parent node does not exist for an insert operation.
57 #[error("parent node not found: {0}")]
58 ParentNotFound(u32),
59
60 /// A child ID already exists in the instance.
61 #[error("duplicate node ID: {0}")]
62 DuplicateNodeId(u32),
63}