Skip to content

Commit

Permalink
Fix improving error handling when Docker daemon is not running
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Aug 3, 2023
1 parent 95c52b7 commit 4866af8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ pytest-mqtt changelog
in progress
===========

- Fix improving error handling when Docker daemon is not running.


2023-07-28 0.3.0
================
Expand Down
7 changes: 5 additions & 2 deletions pytest_mqtt/mosquitto.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ def pull_image(self):
docker_client.images.pull(image_name)

def run(self):
docker_client = docker.from_env(version=self.docker_version)
docker_url = docker_client.api.base_url
try:
docker_client = docker.from_env(version=self.docker_version)
docker_url = docker_client.api.base_url
except Exception:
raise ConnectionError("Cannot connect to the Docker daemon. Is the docker daemon running?")
try:
docker_client.ping()
except Exception:
Expand Down

0 comments on commit 4866af8

Please sign in to comment.