daedalus_runtime/executor/
errors.rs1#[non_exhaustive]
9#[derive(Debug, Clone, PartialEq, Eq)]
10pub enum NodeError {
11 Handler(String),
12 InvalidInput(String),
13 BackpressureDrop(String),
14}
15
16impl std::fmt::Display for NodeError {
17 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
18 match self {
19 NodeError::Handler(s) => write!(f, "{s}"),
20 NodeError::InvalidInput(s) => write!(f, "invalid input: {s}"),
21 NodeError::BackpressureDrop(s) => write!(f, "backpressure drop: {s}"),
22 }
23 }
24}
25
26impl std::error::Error for NodeError {}
27
28impl NodeError {
29 pub fn code(&self) -> &'static str {
31 match self {
32 NodeError::Handler(_) => "handler_error",
33 NodeError::InvalidInput(_) => "invalid_input",
34 NodeError::BackpressureDrop(_) => "backpressure_drop",
35 }
36 }
37
38 pub fn retryable(&self) -> bool {
40 matches!(self, NodeError::BackpressureDrop(_))
41 }
42}
43
44#[non_exhaustive]
52#[derive(Debug, PartialEq, Eq)]
53pub enum ExecuteError {
54 GpuUnavailable {
56 segment: Vec<daedalus_planner::NodeRef>,
57 },
58 HandlerFailed { node: String, error: NodeError },
60 HandlerPanicked { node: String, message: String },
62}
63
64impl std::fmt::Display for ExecuteError {
65 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
66 match self {
67 ExecuteError::GpuUnavailable { .. } => write!(f, "gpu unavailable for segment"),
68 ExecuteError::HandlerFailed { node, error } => {
69 write!(f, "handler failed on node {node}: {error}")
70 }
71 ExecuteError::HandlerPanicked { node, message } => {
72 write!(f, "handler panicked on node {node}: {message}")
73 }
74 }
75 }
76}
77
78impl std::error::Error for ExecuteError {}
79
80impl ExecuteError {
81 pub fn code(&self) -> &'static str {
83 match self {
84 ExecuteError::GpuUnavailable { .. } => "gpu_unavailable",
85 ExecuteError::HandlerFailed { .. } => "handler_failed",
86 ExecuteError::HandlerPanicked { .. } => "handler_panicked",
87 }
88 }
89
90 pub fn retryable(&self) -> bool {
92 matches!(self, ExecuteError::GpuUnavailable { .. })
93 }
94}