From 0507f80fcdbe1b0caba27241d580595c5931f8c8 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Tue, 14 Apr 2015 10:26:39 -0700 Subject: [PATCH] discogs: Handle errors on auth setup (fix #1417) --- beetsplug/discogs.py | 9 +++++++-- docs/changelog.rst | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/beetsplug/discogs.py b/beetsplug/discogs.py index c58dd9a8d..c4660ae76 100644 --- a/beetsplug/discogs.py +++ b/beetsplug/discogs.py @@ -95,7 +95,12 @@ class DiscogsPlugin(BeetsPlugin): def authenticate(self, c_key, c_secret): # Get the link for the OAuth page. auth_client = Client(USER_AGENT, c_key, c_secret) - _, _, url = auth_client.get_authorize_url() + try: + _, _, url = auth_client.get_authorize_url() + except CONNECTION_ERRORS as e: + self._log.debug('connection error: {0}', e) + raise beets.ui.UserError('communication with Discogs failed') + beets.ui.print_("To authenticate with Discogs, visit:") beets.ui.print_(url) @@ -107,7 +112,7 @@ class DiscogsPlugin(BeetsPlugin): raise beets.ui.UserError('Discogs authorization failed') except CONNECTION_ERRORS as e: self._log.debug(u'connection error: {0}', e) - raise beets.ui.UserError('communication with Discogs failed') + raise beets.ui.UserError('Discogs token request failed') # Save the token for later use. self._log.debug('Discogs token {0}, secret {1}', token, secret) diff --git a/docs/changelog.rst b/docs/changelog.rst index 3c4cf6aba..5527730b3 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -25,6 +25,8 @@ Little fixes and improvements: Windows. (Specifically, the console output encoding is guessed separately from the encoding for command-line arguments.) A bug was also fixed where beets would ignore the locale settings and use UTF-8 by default. :bug:`1419` +* :doc:`/plugins/discogs`: Better error handling when we can't communicate + with Discogs on setup. :bug:`1417` 1.3.11 (April 5, 2015) ----------------------