Improve exception handling. (#121)

This commit is contained in:
Felix Fontein
2021-04-08 08:00:01 +02:00
committed by GitHub
parent ff503d9bd7
commit a3b9648233
24 changed files with 168 additions and 98 deletions
+4 -2
View File
@@ -334,9 +334,11 @@ def main():
DockerHostManager(client, results)
client.module.exit_json(**results)
except DockerException as e:
client.fail('An unexpected docker error occurred: {0}'.format(e), exception=traceback.format_exc())
client.fail('An unexpected docker error occurred: {0}'.format(to_native(e)), exception=traceback.format_exc())
except RequestException as e:
client.fail('An unexpected requests error occurred when docker-py tried to talk to the docker daemon: {0}'.format(e), exception=traceback.format_exc())
client.fail(
'An unexpected requests error occurred when docker-py tried to talk to the docker daemon: {0}'.format(to_native(e)),
exception=traceback.format_exc())
if __name__ == '__main__':