discogs: Catch socket errors (#1299)

See also:

https://github.com/discogs/discogs_client/issues/44
This commit is contained in:
Adrian Sampson 2015-02-02 22:27:14 -08:00
parent bb967dd629
commit 8151a40f1f
2 changed files with 6 additions and 1 deletions

View file

@ -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 []

View file

@ -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: