discogs: Handle errors on auth setup (fix #1417)

This commit is contained in:
Adrian Sampson 2015-04-14 10:26:39 -07:00
parent 8fdf995ff9
commit 0507f80fcd
2 changed files with 9 additions and 2 deletions

View file

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

View file

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