1
0
Fork 0
mirror of synced 2024-10-03 10:36:59 +13:00

Better error message when multiple images are found.

This commit is contained in:
Sam Rose 2024-04-03 11:40:14 +01:00
parent 8cffdeda56
commit 258226ddef
No known key found for this signature in database

View file

@ -44,7 +44,11 @@ function getTestcontainers(): ContainerInfo[] {
export function getContainerByImage(image: string) {
const containers = getTestcontainers().filter(x => x.Image.startsWith(image))
if (containers.length > 1) {
throw new Error(`Multiple containers found with image: ${image}`)
let errorMessage = `Multiple containers found starting with image: "${image}"\n\n`
for (const container of containers) {
errorMessage += JSON.stringify(container, null, 2)
}
throw new Error(errorMessage)
}
return containers[0]
}