From f9196104917762d137a44809f27e74c8cf8f5fe2 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Sat, 9 Feb 2019 13:59:37 +0000 Subject: [PATCH 1/2] Improve error message in case of paramiko failure Fix issues where essential error about paramiko dealing code was lost due to ageneric exception that assumed paramiko library was missing. To keep backwards compatibility we keep the custom exception but we also include information from original exception that caused it. It was wrong to believe that only missing paramiko can cause it, even code inside docker-py can thow exceptions, and NamedException is very broad exception class. Signed-off-by: Sorin Sbarnea --- docker/api/client.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docker/api/client.py b/docker/api/client.py index 9b70554902..9c1f3f09e0 100644 --- a/docker/api/client.py +++ b/docker/api/client.py @@ -161,9 +161,10 @@ def __init__(self, base_url=None, version=None, self._custom_adapter = SSHAdapter( base_url, timeout, pool_connections=num_pools ) - except NameError: + except NameError as e: + # do not hide orrinal exception as it may contain variou raise DockerException( - 'Install paramiko package to enable ssh:// support' + "Paramiko failure while trying ssh:// protocol:\n%s" % e ) self.mount('http+docker://ssh', self._custom_adapter) self._unmount('http://', 'https://') From 1848bb66c122871c6ab776060ddd956571688fa9 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Tue, 19 Feb 2019 15:03:24 +0000 Subject: [PATCH 2/2] Update client.py --- docker/api/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/api/client.py b/docker/api/client.py index 9c1f3f09e0..7ad4618528 100644 --- a/docker/api/client.py +++ b/docker/api/client.py @@ -162,7 +162,7 @@ def __init__(self, base_url=None, version=None, base_url, timeout, pool_connections=num_pools ) except NameError as e: - # do not hide orrinal exception as it may contain variou + # do not hide orriginal exception as it may contain important info raise DockerException( "Paramiko failure while trying ssh:// protocol:\n%s" % e )