contain_rs_core/
error.rs

1use std::{io, process::Output};
2
3use crate::{container::WaitStrategy, rt::ContainerStatus};
4
5pub type ContainerResult<T> = std::result::Result<T, ContainersError>;
6
7#[derive(Debug, thiserror::Error)]
8pub enum ContainersError {
9    #[error("IO Error")]
10    IOError(#[from] io::Error),
11    #[error("Command exited with non zero exit-code")]
12    CommandError(Output),
13    #[error("Error parsing json")]
14    JsonError(#[from] serde_json::Error),
15    #[error("Unexpected container stauts: {status:?}")]
16    ContainerStatusError { status: ContainerStatus },
17    #[error("Container does not exist: {container_name}")]
18    ContainerNotExists { container_name: String },
19    #[error("Waiting for container to be ready failed. Container name: {container_name}, wait strategy: {wait_strategy:?}")]
20    ContainerWaitFailed {
21        container_name: String,
22        wait_strategy: WaitStrategy,
23    },
24    #[error("Invalid image name: {name}")]
25    InvalidImageName { name: String },
26}