1mod cmd;
2mod container;
3mod container_builder;
4mod container_functions;
5mod container_operations;
6#[cfg(test)]
7mod container_test;
8mod container_types;
9mod health_check;
10mod health_check_script;
11mod images;
12
13use std::error::Error;
14use std::fmt;
15use std::io;
16
17#[derive(Debug)]
19pub enum NerdctlError {
20 CommandExecutionFailed(io::Error),
22 CommandFailed(String),
24 JsonParseError(String),
26 ConversionError(String),
28 Other(String),
30}
31
32impl fmt::Display for NerdctlError {
33 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
34 match self {
35 NerdctlError::CommandExecutionFailed(e) => {
36 write!(f, "Failed to execute nerdctl command: {}", e)
37 }
38 NerdctlError::CommandFailed(e) => write!(f, "Nerdctl command failed: {}", e),
39 NerdctlError::JsonParseError(e) => write!(f, "Failed to parse JSON: {}", e),
40 NerdctlError::ConversionError(e) => write!(f, "Conversion error: {}", e),
41 NerdctlError::Other(e) => write!(f, "{}", e),
42 }
43 }
44}
45
46impl Error for NerdctlError {
47 fn source(&self) -> Option<&(dyn Error + 'static)> {
48 match self {
49 NerdctlError::CommandExecutionFailed(e) => Some(e),
50 _ => None,
51 }
52 }
53}
54
55pub use cmd::*;
56pub use container_functions::*;
57pub use container_types::{Container, ContainerStatus, HealthCheck, ResourceUsage};
58pub use health_check_script::*;
59pub use images::*;