Skip to main content

substrate_kit/
error.rs

1//! Error type for Substrate Kit operations.
2
3use thiserror::Error;
4
5///
6/// `#[non_exhaustive]`: new variants are additive from here on. (Adding the
7/// attribute, and the `InvalidSpec` variant below, is the one breaking change
8/// of the 0.1.0 release for anyone matching exhaustively; pre-1.0.)
9#[derive(Debug, Error)]
10#[non_exhaustive]
11pub enum SubstrateError {
12    #[error("not implemented: {0}")]
13    NotImplemented(&'static str),
14
15    #[error("io: {0}")]
16    Io(#[from] std::io::Error),
17
18    /// A dockerd Engine API call (via `bollard`) failed. Purely a
19    /// mechanics-layer failure — this crate never inspects the underlying
20    /// `bollard::errors::Error` to make an authorization decision, only to
21    /// distinguish transient/not-found conditions (see `lifecycle`'s
22    /// `is_not_found` helper) from real failures.
23    #[error("dockerd: {0}")]
24    Docker(#[from] bollard::errors::Error),
25
26    /// An OS-level fact (cgroup path, mount-namespace handle, uid) could
27    /// not be resolved from a running container/process — e.g. malformed
28    /// `/proc` content, an unsupported cgroup hierarchy, or a container
29    /// that isn't actually running. Distinct from `Io`, which covers the
30    /// read itself failing (including permission-denied reading another
31    /// user's `/proc/<pid>/ns/*`, a real and expected boundary — see
32    /// `mount::resolve_mount_namespace`'s doc).
33    #[error("could not resolve {0}")]
34    Resolve(String),
35
36    /// A caller-supplied spec (`ContainerSpec`, `VolumeMount`, `PortMapping`)
37    /// was rejected before any dockerd call was made — a malformed volume
38    /// name, a relative mount target, a duplicate port publish, etc.
39    #[error("invalid spec: {0}")]
40    InvalidSpec(String),
41
42    /// A poll (e.g. waiting for a container to reach and stay at Running)
43    /// exceeded its deadline.
44    #[error("timed out: {0}")]
45    Timeout(String),
46}