diff --git a/metadata.json b/metadata.json index c6d4cd1..5aa3399 100755 --- a/metadata.json +++ b/metadata.json @@ -14,5 +14,5 @@ "43", "44" ], - "version": 26 + "version": 27 } diff --git a/src/data/container.js b/src/data/container.js index 4f93fdf..60dda1b 100755 --- a/src/data/container.js +++ b/src/data/container.js @@ -61,7 +61,12 @@ var getImages = async (engine) => { const result = await CommandLine.execute( COMMAND_TEMPLATE_IMAGES.replace(PARAM_ENGINE, engine), ); - return parseImages(result); + const images = parseImages(result); + if (images.length === 0) { + Log.w(LOGTAG, `No ${engine} image detected!`); + throw new Error("No image detected!"); + } + return images; }; /** diff --git a/src/data/dockerRepository.js b/src/data/dockerRepository.js index e089395..a3230e4 100755 --- a/src/data/dockerRepository.js +++ b/src/data/dockerRepository.js @@ -24,7 +24,12 @@ var isInstalled = () => Container.isInstalled(ENGINE); */ /* exported getContainers */ var getContainers = async () => { - var containers = await Container.getContainers(ENGINE); + var containers = []; + try { + containers = await Container.getContainers(ENGINE); + } catch (error) { + Log.w(LOGTAG, `Cannot retrieve ${ENGINE} containers: ${error.message}`); + } if (Settings.shouldShowDockerImages()) { try { const images = await Container.getImages(ENGINE); @@ -33,6 +38,9 @@ var getContainers = async () => { Log.w(LOGTAG, `Cannot retrieve ${ENGINE} images: ${error.message}`); } } + if (containers.length === 0) { + throw new Error("No container detected!"); + } return containers; }; diff --git a/src/data/podmanRepository.js b/src/data/podmanRepository.js index 9e9e034..d52fb1b 100755 --- a/src/data/podmanRepository.js +++ b/src/data/podmanRepository.js @@ -24,7 +24,12 @@ var isInstalled = () => Container.isInstalled(ENGINE); */ /* exported getContainers */ var getContainers = async () => { - var containers = await Container.getContainers(ENGINE); + var containers = []; + try { + containers = await Container.getContainers(ENGINE); + } catch (error) { + Log.w(LOGTAG, `Cannot retrieve ${ENGINE} containers: ${error.message}`); + } if (Settings.shouldShowPodmanImages()) { try { const images = await Container.getImages(ENGINE); @@ -33,6 +38,9 @@ var getContainers = async () => { Log.w(LOGTAG, `Cannot retrieve ${ENGINE} images: ${error.message}`); } } + if (containers.length === 0) { + throw new Error("No container detected!"); + } return containers; };