Files
steep/crates/devcontainer-rs/src/errors.rs
T
qpismont 3078ba5705
ci/woodpecker/push/tests Pipeline was canceled
clean project structure
2026-10-13 19:57:24 +00:00

55 lines
1.5 KiB
Rust

//! Crate errors: container daemon failures and `devcontainer.json` parsing failures.
use std::{path::PathBuf, time::Duration};
use bollard::errors::Error as BollardError;
#[derive(Debug, thiserror::Error)]
pub enum ContainerError {
/// The daemon is unreachable, or rejected a request.
#[error("container daemon request failed: {source}")]
Request {
#[from]
source: BollardError,
},
/// An operation exceeded its timeout.
#[error("`{operation}` timed out after {timeout:?}")]
Timeout {
operation: String,
timeout: Duration,
},
/// The image build failed.
#[error("image build failed: {message}")]
Build { message: String },
/// The daemon replied with something other than what was expected.
#[error("{0}")]
Unexpected(String),
}
#[derive(Debug, thiserror::Error)]
pub enum ParseError {
#[error("failed to read devcontainer file `{path}`: {source}")]
Read {
path: PathBuf,
source: std::io::Error,
},
#[error("invalid devcontainer JSON in `{path}`: {source}")]
Json {
path: PathBuf,
source: serde_json::Error,
},
#[error("container file `{0}` does not exist or is not a regular file")]
ContainerFileNotFound(PathBuf),
#[error("devcontainer file `{0}` declares neither `image` nor `build`")]
MissingImageOrBuild(PathBuf),
#[error("the devcontainer file path has no parent directory: `{0}`")]
InvalidDevContainerPath(PathBuf),
}