cranpose_core/
node_error.rs1#[derive(Debug, Clone, PartialEq, Eq)]
3pub enum NodeError {
4 Missing {
6 id: NodeId,
8 },
9 TypeMismatch {
11 id: NodeId,
13 expected: &'static str,
15 },
16 MissingContext {
18 id: NodeId,
20 reason: &'static str,
22 },
23 AlreadyExists {
25 id: NodeId,
27 },
28 MalformedCommandPayload {
30 tag: &'static str,
32 },
33 SlotHostUnavailable {
35 operation: &'static str,
37 reason: &'static str,
39 },
40 RecompositionLimitExceeded {
42 operation: &'static str,
44 limit: usize,
46 },
47}
48
49impl std::fmt::Display for NodeError {
50 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
51 match self {
52 Self::Missing { id } => write!(f, "node {id} missing"),
53 Self::TypeMismatch { id, expected } => {
54 write!(f, "node {id} type mismatch; expected {expected}")
55 }
56 Self::MissingContext { id, reason } => {
57 write!(f, "missing context for node {id}: {reason}")
58 }
59 Self::AlreadyExists { id } => {
60 write!(f, "node {id} already exists")
61 }
62 Self::MalformedCommandPayload { tag } => {
63 write!(f, "command queue missing or invalid {tag} payload")
64 }
65 Self::SlotHostUnavailable { operation, reason } => {
66 write!(f, "{operation} cannot access slot host: {reason}")
67 }
68 Self::RecompositionLimitExceeded { operation, limit } => {
69 write!(
70 f,
71 "{operation} exceeded {limit} iterations while reconciling composition"
72 )
73 }
74 }
75 }
76}
77
78impl std::error::Error for NodeError {}
79
80use crate::NodeId;