55 lines
1.5 KiB
Rust
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),
|
|
}
|