Skip to content

Commit 7dbd2a6

Browse files
Update error messaging when a container is already running (#2234)
1 parent 121c544 commit 7dbd2a6

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

  • cmd/soroban-cli/src/commands/container

cmd/soroban-cli/src/commands/container/start.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ pub enum Error {
2828

2929
#[error("⛔ ️Failed to create container: {0}")]
3030
CreateContainerFailed(#[from] bollard::errors::Error),
31+
32+
#[error("⛔ ️ a container named {0:?} already running")]
33+
ContainerAlreadyRunning(String),
3134
}
3235

3336
#[derive(Debug, clap::Parser, Clone)]
@@ -139,7 +142,18 @@ impl Runner {
139142
}),
140143
config,
141144
)
142-
.await?;
145+
.await
146+
.map_err(|e| match &e {
147+
bollard::errors::Error::DockerResponseServerError { status_code, .. } => {
148+
if *status_code == 409 {
149+
return Error::ContainerAlreadyRunning(
150+
self.container_name().get_internal_container_name(),
151+
);
152+
}
153+
Error::CreateContainerFailed(e)
154+
}
155+
_ => Error::CreateContainerFailed(e),
156+
})?;
143157

144158
docker
145159
.start_container(

0 commit comments

Comments
 (0)