-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patherrors.rs
More file actions
151 lines (138 loc) · 4.83 KB
/
Copy patherrors.rs
File metadata and controls
151 lines (138 loc) · 4.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
//! Error types for provisioned container operations
//!
//! This module contains all error types related to container provisioning and management.
//! The errors are organized by logical problem categories to make troubleshooting easier.
/// Top-level error type for container operations
///
/// This error type organizes failures by what logically went wrong, making it easier
/// to understand and troubleshoot issues during container provisioning.
#[derive(Debug, thiserror::Error)]
pub enum ContainerError {
/// Problems with the Docker image (build failures, Docker daemon issues)
#[error("Container image problem: {source}")]
ContainerImage {
#[from]
source: ContainerImageError,
},
/// Problems with container runtime (startup, configuration)
#[error("Container runtime problem: {source}")]
ContainerRuntime {
#[from]
source: ContainerRuntimeError,
},
/// Problems with container networking (port mapping, connectivity)
#[error("Container networking problem: {source}")]
ContainerNetworking {
#[from]
source: ContainerNetworkingError,
},
/// Problems with SSH setup and connectivity
#[error("SSH setup problem: {source}")]
SshSetup {
#[from]
source: SshSetupError,
},
}
/// Container image-related errors
///
/// These errors occur when there are problems with the Docker image that needs to run.
/// This includes building the image, Docker daemon issues, or missing dependencies.
#[derive(Debug, thiserror::Error)]
pub enum ContainerImageError {
/// Docker image build process failed
#[error("Failed to build Docker image '{image_name}:{image_tag}': {reason}")]
BuildFailed {
image_name: String,
image_tag: String,
reason: String,
#[source]
source: super::image_builder::ContainerBuildError,
},
/// Docker daemon or command execution issues
#[error("Docker command execution failed for image '{image_name}:{image_tag}': {reason}")]
DockerCommandFailed {
image_name: String,
image_tag: String,
reason: String,
#[source]
source: std::io::Error,
},
}
/// Container runtime errors
///
/// These errors occur during container lifecycle operations - starting, configuring,
/// or managing the running container.
#[derive(Debug, thiserror::Error)]
pub enum ContainerRuntimeError {
/// Container configuration is invalid or malformed
#[error("Invalid container configuration for image '{image_name}:{image_tag}': {reason}")]
InvalidConfiguration {
image_name: String,
image_tag: String,
reason: String,
#[source]
source: super::config_builder::ContainerConfigError,
},
/// Container failed to start or reach expected state
#[error("Container failed to start for image '{image_name}:{image_tag}': {reason}")]
StartupFailed {
image_name: String,
image_tag: String,
reason: String,
#[source]
source: testcontainers::TestcontainersError,
},
}
/// Container networking errors
///
/// These errors occur when there are problems with container network access,
/// port mapping, or connectivity.
#[derive(Debug, thiserror::Error)]
pub enum ContainerNetworkingError {
/// Failed to get mapped ports from container
#[error("Failed to get mapped port {internal_port} from container '{container_id}': {reason}")]
PortMappingFailed {
container_id: String,
internal_port: u16,
reason: String,
#[source]
source: testcontainers::TestcontainersError,
},
}
/// SSH setup and connectivity errors
///
/// These errors occur when setting up or testing SSH access to the container.
/// This includes SSH service readiness, key setup, and connection testing.
#[derive(Debug, thiserror::Error)]
pub enum SshSetupError {
/// SSH service not ready within timeout
#[error(
"SSH service not ready on container '{container_id}' port {ssh_port} after {timeout_secs}s"
)]
ServiceTimeout {
container_id: String,
ssh_port: u16,
timeout_secs: u64,
},
/// SSH key setup failed inside container
#[error("Failed to setup SSH keys in container '{container_id}': {reason}")]
KeySetupFailed {
container_id: String,
reason: String,
#[source]
source: super::actions::ssh_key_setup::SshKeySetupError,
},
/// SSH connectivity test failed
#[error(
"SSH connectivity test failed for container '{container_id}' on port {ssh_port}: {reason}"
)]
ConnectivityTestFailed {
container_id: String,
ssh_port: u16,
reason: String,
#[source]
source: super::actions::ssh_wait::SshWaitError,
},
}
/// Result type alias for container operations
pub type Result<T> = std::result::Result<T, Box<ContainerError>>;