mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-15 11:32:05 +00:00
Improve error handling. (#1035)
This commit is contained in:
parent
8bae4e9c6d
commit
511cfe52ca
3
changelogs/fragments/1034-error-msg.yml
Normal file
3
changelogs/fragments/1034-error-msg.yml
Normal file
@ -0,0 +1,3 @@
|
||||
bugfixes:
|
||||
- "vendored Docker SDK for Python - do not assume that ``KeyError`` is always for ``ApiVersion`` when querying version fails
|
||||
(https://github.com/ansible-collections/community.docker/issues/1033, https://github.com/ansible-collections/community.docker/pull/1034)."
|
||||
@ -202,7 +202,14 @@ class APIClient(
|
||||
|
||||
def _retrieve_server_version(self):
|
||||
try:
|
||||
return self.version(api_version=False)["ApiVersion"]
|
||||
version_result = self.version(api_version=False)
|
||||
except Exception as e:
|
||||
raise DockerException(
|
||||
'Error while fetching server API version: {0}'.format(e)
|
||||
)
|
||||
|
||||
try:
|
||||
return version_result["ApiVersion"]
|
||||
except KeyError:
|
||||
raise DockerException(
|
||||
'Invalid response from docker daemon: key "ApiVersion"'
|
||||
@ -210,7 +217,7 @@ class APIClient(
|
||||
)
|
||||
except Exception as e:
|
||||
raise DockerException(
|
||||
'Error while fetching server API version: {0}'.format(e)
|
||||
'Error while fetching server API version: {0}. Response seems to be broken.'.format(e)
|
||||
)
|
||||
|
||||
def _set_request_timeout(self, kwargs):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user