lightshuttle_export/error.rs
1//! Error type returned by the export pipeline.
2
3use lightshuttle_spec::SpecError;
4
5/// Shorthand alias for `std::result::Result<T, ExportError>`.
6pub type Result<T> = std::result::Result<T, ExportError>;
7
8/// Errors raised while lowering a manifest or emitting artifacts.
9#[derive(Debug, thiserror::Error)]
10pub enum ExportError {
11 /// Resolving a manifest resource into a container specification
12 /// failed during lowering.
13 #[error("failed to resolve resource `{resource}`")]
14 Spec {
15 /// Resource whose resolution failed.
16 resource: String,
17 /// Underlying specification error.
18 #[source]
19 source: SpecError,
20 },
21
22 /// An emitter could not represent a resource for its target (for
23 /// example, a locally built image has no registry reference to put
24 /// in a Kubernetes manifest).
25 #[error("`{resource}` cannot be exported to {target}: {reason}")]
26 Unsupported {
27 /// Resource that cannot be represented.
28 resource: String,
29 /// Target that rejected it.
30 target: &'static str,
31 /// Why the resource is unsupported for this target.
32 reason: String,
33 },
34}