XOAUTH2: improve error message while trying to get access token

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/338
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Nicolas Sebrecht 2016-08-15 02:07:14 +02:00
parent 1884fd7ef6
commit 71d86b6d47
1 changed files with 6 additions and 0 deletions

View File

@ -253,6 +253,12 @@ class IMAPServer(object):
try:
response = urllib.urlopen(
self.oauth2_request_url, urllib.urlencode(params)).read()
except Exception as e:
try:
msg = "%s (configuration is: %s)"% (e, str(params))
except Exception as eparams:
msg = "%s [cannot display configuration: %s]"% (e, eparams)
six.reraise(type(e), type(e)(msg), exc_info()[2])
finally:
socket.socket = original_socket