lightshuttle_runtime/lifecycle/error.rs
1//! Error type returned by [`crate::LifecycleManager`] and
2//! [`crate::LifecyclePlan`].
3
4use std::time::Duration;
5
6use crate::error::RuntimeError;
7
8/// Errors raised by the lifecycle layer.
9#[derive(Debug, thiserror::Error)]
10pub enum LifecycleError {
11 /// The dependency graph contains a cycle.
12 #[error("cycle detected in dependency graph: {0}")]
13 Cycle(String),
14
15 /// Converting a manifest resource into a [`crate::ContainerSpec`] failed.
16 #[error("manifest conversion failed for `{resource}`")]
17 SpecBuild {
18 /// Resource whose conversion failed.
19 resource: String,
20 /// Underlying runtime error.
21 #[source]
22 source: RuntimeError,
23 },
24
25 /// A resource failed to start.
26 #[error("failed to start resource `{resource}`")]
27 Start {
28 /// Resource that failed.
29 resource: String,
30 /// Underlying runtime error.
31 #[source]
32 source: RuntimeError,
33 },
34
35 /// A resource failed to stop cleanly.
36 #[error("failed to stop resource `{resource}`")]
37 Stop {
38 /// Resource that failed.
39 resource: String,
40 /// Underlying runtime error.
41 #[source]
42 source: RuntimeError,
43 },
44
45 /// A resource never became healthy within the configured timeout.
46 #[error("resource `{resource}` healthcheck timed out after {timeout:?}")]
47 HealthcheckTimeout {
48 /// Resource that did not become healthy.
49 resource: String,
50 /// Configured timeout.
51 timeout: Duration,
52 },
53
54 /// A dependency of the resource failed.
55 #[error("dependency `{dependency}` for `{resource}` failed: {reason}")]
56 DependencyFailed {
57 /// Resource whose start was blocked.
58 resource: String,
59 /// Dependency that failed.
60 dependency: String,
61 /// Reason reported by the failed dependency.
62 reason: String,
63 },
64
65 /// A reference targets a resource that does not exist in the plan.
66 #[error("resource `{0}` not found in the current plan")]
67 ResourceNotFound(String),
68}