fix: error handling of container failures

This commit is contained in:
wancat committed 2023-09-01 13:49:00 +08:00
1 parent 3fdbca89f3
commit 8b5f7175a7
2 files changed
+64 -67

No files matched your search

+4 -9
View File
@@ -35,16 +35,11 @@ export async function createContainer(name) {
export async function getAndStartContainer(id) {
console.log(`Getting container: ${id}`)
let container
try {
container = engine.getContainer(id)
if (!(await container.inspect()).State.Running) {
await container.start()
}
return container
} catch (error) {
throw new Error(`Container not found: ${id}`)
const container = engine.getContainer(id)
if (!(await container.inspect()).State.Running) {
await container.start()
}
return container
}
export async function attachContainer(container, { token }) {