Skip to main content

lightshuttle_export/
error.rs

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