You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2020/10/04 16:58:45 UTC
[libcloud] branch trunk updated: Update exception handling code so
it also works correctly on windows.
This is an automated email from the ASF dual-hosted git repository.
tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git
The following commit(s) were added to refs/heads/trunk by this push:
new 540ef1f Update exception handling code so it also works correctly on windows.
540ef1f is described below
commit 540ef1f260e8aaefbeafb103939565e1d4f00b51
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Sun Oct 4 18:58:21 2020 +0200
Update exception handling code so it also works correctly on windows.
---
libcloud/common/ovh.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/libcloud/common/ovh.py b/libcloud/common/ovh.py
index 778c352..6e25b80 100644
--- a/libcloud/common/ovh.py
+++ b/libcloud/common/ovh.py
@@ -23,8 +23,6 @@ try:
except ImportError:
import json # type: ignore
-import requests
-
from libcloud.utils.py3 import httplib
from libcloud.utils.connection import get_response_object
from libcloud.common.types import InvalidCredsError
@@ -142,7 +140,7 @@ class OvhConnection(ConnectionUserAndKey):
try:
httpcon.request(method='POST', url=action, body=data,
headers=headers)
- except requests.exceptions.ConnectionError as e:
+ except Exception as e:
handle_and_rethrow_user_friendly_invalid_region_error(
host=self.host, e=e)
@@ -213,7 +211,7 @@ class OvhConnection(ConnectionUserAndKey):
return super(OvhConnection, self)\
.request(action, params=params, data=data, headers=headers,
method=method, raw=raw)
- except requests.exceptions.ConnectionError as e:
+ except Exception as e:
handle_and_rethrow_user_friendly_invalid_region_error(
host=self.host, e=e)
@@ -226,7 +224,9 @@ def handle_and_rethrow_user_friendly_invalid_region_error(host, e):
In most cases this error indicates user passed invalid ``region`` argument
to the driver constructor.
"""
- if 'name or service not known' in str(e).lower():
+ msg = str(e).lower()
+
+ if 'name or service not known' in msg or 'getaddrinfo failed' in msg:
raise ValueError('Received "name or service not known" error '
'when sending a request. This likely '
'indicates invalid region argument was '