1use frp_plexus::{BlockId, EdgeId, PortId};
4use thiserror::Error;
5
6#[derive(Debug, Error)]
7pub enum EngineError {
8 #[error("cycle detected in edge graph")]
9 CycleDetected,
10
11 #[error("transform not found: '{0}'")]
12 TransformNotFound(String),
13
14 #[error("execution failed: {0}")]
15 ExecutionFailed(String),
16
17 #[error("port not found: {0:?}")]
18 PortNotFound(PortId),
19
20 #[error("block not found: {0:?}")]
21 BlockNotFound(BlockId),
22
23 #[error("edge not found: {0:?}")]
24 EdgeNotFound(EdgeId),
25
26 #[error("validation failed: {0}")]
27 ValidationFailed(String),
28}
29
30#[cfg(test)]
31mod tests {
32 use super::*;
33
34 #[test]
35 fn cycle_detected_display() {
36 let e = EngineError::CycleDetected;
37 assert_eq!(e.to_string(), "cycle detected in edge graph");
38 }
39
40 #[test]
41 fn transform_not_found_display() {
42 let e = EngineError::TransformNotFound("my_fn".to_string());
43 assert_eq!(e.to_string(), "transform not found: 'my_fn'");
44 }
45
46 #[test]
47 fn port_not_found_display() {
48 let e = EngineError::PortNotFound(PortId::new(7));
49 assert!(e.to_string().contains("7"));
50 }
51}