From 8151a40f1fe157750dbb995318240b319e73e3d3 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Mon, 2 Feb 2015 22:27:14 -0800 Subject: [PATCH] discogs: Catch socket errors (#1299) See also: https://github.com/discogs/discogs_client/issues/44 --- beetsplug/discogs.py | 5 ++++- docs/changelog.rst | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/beetsplug/discogs.py b/beetsplug/discogs.py index 86af9da06..d63aef8ae 100644 --- a/beetsplug/discogs.py +++ b/beetsplug/discogs.py @@ -90,6 +90,9 @@ class DiscogsPlugin(BeetsPlugin): token, secret = auth_client.get_access_token(code) except DiscogsAPIError: raise beets.ui.UserError('Discogs authorization failed') + except (ConnectionError, socket.error) as e: + self._log.debug(u'connection error: {0}', e) + raise beets.ui.UserError('communication with Discogs failed') # Save the token for later use. self._log.debug('Discogs token {0}, secret {1}', token, secret) @@ -122,7 +125,7 @@ class DiscogsPlugin(BeetsPlugin): except DiscogsAPIError as e: self._log.debug(u'API Error: {0} (query: {1})', e, query) return [] - except ConnectionError as e: + except (ConnectionError, socket.error) as e: self._log.debug(u'HTTP Connection Error: {0}', e) return [] diff --git a/docs/changelog.rst b/docs/changelog.rst index ba5934c4c..9be8779ea 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -96,6 +96,8 @@ Fixes: * :doc:`/plugins/scrub`: Log an error instead of stopping when the ``beet scrub`` command cannot write a file. Also, avoid problems on Windows with Unicode filenames. :bug:`1297` +* :doc:`/plugins/discogs`: Handle and log more kinds of communication + errors. :bug:`1299` For developers: