Skip to main content

lenso_runner/replicated/
error.rs

1use std::fmt;
2
3use lenso_kernel::{RuntimeFailure, ShutdownOutcome};
4
5/// A native Runner startup or lane-lifecycle failure.
6#[derive(Clone, Debug, Eq, PartialEq)]
7pub enum ReplicatedRunnerError {
8    /// The immutable Plan failed validation before any lane started.
9    InvalidPlan { detail: String },
10    /// One lane could not construct or start its Kernel replica.
11    LaneStartup { lane: String, detail: String },
12    /// A generated request Capability was not registered with the native transfer catalog.
13    MissingCrossLaneRequestTransfer { capability: String },
14    /// A generated stream Capability was not registered with the native transfer catalog.
15    MissingCrossLaneStreamTransfer { capability: String },
16    /// A generated Event Capability was not registered with the native transfer catalog.
17    MissingCrossLaneEventTransfer { capability: String },
18    /// A lane stopped accepting Runner commands unexpectedly.
19    LaneUnavailable { lane: String },
20    /// A lane thread panicked while starting, running, or stopping.
21    LanePanicked { lane: String },
22    /// One Kernel replica reached a terminal runtime failure.
23    LaneRuntimeFailure { lane: String, error: RuntimeFailure },
24    /// One Kernel replica did not stop cleanly.
25    LaneShutdown {
26        lane: String,
27        outcome: ShutdownOutcome,
28    },
29}
30
31impl fmt::Display for ReplicatedRunnerError {
32    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
33        match self {
34            Self::InvalidPlan { detail } => {
35                write!(formatter, "invalid Resolved App Plan: {detail}")
36            }
37            Self::LaneStartup { lane, detail } => {
38                write!(
39                    formatter,
40                    "Execution Lane `{lane}` failed to start: {detail}"
41                )
42            }
43            Self::MissingCrossLaneRequestTransfer { capability } => write!(
44                formatter,
45                "Capability `{capability}` has no registered native cross-lane request transfer"
46            ),
47            Self::MissingCrossLaneStreamTransfer { capability } => write!(
48                formatter,
49                "Capability `{capability}` has no registered native cross-lane stream transfer"
50            ),
51            Self::MissingCrossLaneEventTransfer { capability } => write!(
52                formatter,
53                "Capability `{capability}` has no registered native cross-lane Event transfer"
54            ),
55            Self::LaneUnavailable { lane } => {
56                write!(formatter, "Execution Lane `{lane}` is unavailable")
57            }
58            Self::LanePanicked { lane } => write!(formatter, "Execution Lane `{lane}` panicked"),
59            Self::LaneRuntimeFailure { lane, error } => write!(
60                formatter,
61                "Execution Lane `{lane}` reached a terminal runtime failure: {error:?}"
62            ),
63            Self::LaneShutdown { lane, outcome } => write!(
64                formatter,
65                "Execution Lane `{lane}` stopped with {outcome:?}"
66            ),
67        }
68    }
69}
70
71impl std::error::Error for ReplicatedRunnerError {}