taktora_executor/
error.rs1use crate::task_id::TaskId;
4
5pub type ItemError = Box<dyn std::error::Error + Send + Sync + 'static>;
8
9#[derive(thiserror::Error, Debug)]
11#[non_exhaustive]
12pub enum ExecutorError {
13 #[error("iceoryx2: {0}")]
17 Iceoryx2(String),
18
19 #[error("invalid graph: {0}")]
21 InvalidGraph(String),
22
23 #[error("trigger declaration failed: {0}")]
26 DeclareTriggers(String),
27
28 #[error("item error in task {task_id}: {source}")]
30 Item {
31 task_id: TaskId,
33 #[source]
35 source: ItemError,
36 },
37
38 #[error("executor already running")]
40 AlreadyRunning,
41
42 #[error("runner thread join failed")]
44 RunnerJoin,
45
46 #[error("builder misuse: {0}")]
48 Builder(String),
49
50 #[error("task `{0}` not found")]
52 TaskNotFound(TaskId),
53
54 #[error("task `{0}` is not in fault state")]
57 TaskNotFaulted(TaskId),
58
59 #[error("executor is not in fault state")]
62 ExecutorNotFaulted,
63}
64
65impl ExecutorError {
66 #[must_use]
68 pub fn iceoryx2(err: impl core::fmt::Display) -> Self {
69 Self::Iceoryx2(err.to_string())
70 }
71}
72
73#[cfg(test)]
74mod tests {
75 use super::*;
76
77 #[test]
78 fn item_error_roundtrip() {
79 let source: ItemError = Box::new(std::io::Error::other("boom"));
80 let err = ExecutorError::Item {
81 task_id: "task-1".into(),
82 source,
83 };
84 let s = format!("{err}");
85 assert!(s.contains("task-1"));
86 assert!(s.contains("boom"));
87 }
88
89 #[test]
90 fn iceoryx2_helper_renders_display() {
91 #[derive(Debug, thiserror::Error)]
92 #[error("whatever happened")]
93 struct Whatever;
94 let e = ExecutorError::iceoryx2(Whatever);
95 assert!(matches!(e, ExecutorError::Iceoryx2(_)));
96 assert!(format!("{e}").contains("whatever happened"));
97 }
98}