From feff686907e44fef6ef0c5b61623051407261d50 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 28 Nov 2015 20:57:56 +0100 Subject: [PATCH] Handle ConnectionError without a response E.g.: ``` ConnectionError: HTTPSConnectionPool(host='api.soundcloud.com', port=443): Max retries exceeded with url: /me.json?client_id=XXX (Caused by NewConnectionError(': Failed to establish a new connection: [Errno -2] Name or service not known',)) ``` --- mopidy_soundcloud/soundcloud.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mopidy_soundcloud/soundcloud.py b/mopidy_soundcloud/soundcloud.py index 220c365..73b82f3 100644 --- a/mopidy_soundcloud/soundcloud.py +++ b/mopidy_soundcloud/soundcloud.py @@ -77,7 +77,7 @@ def __init__(self, config): try: self._get('me.json') except Exception as err: - if err.response.status_code == 401: + if err.response is not None and err.response.status_code == 401: logger.error('Invalid "auth_token" used for SoundCloud ' 'authentication!') else: