Skip to content

Commit cd94545

Browse files
committed
WIP changes for PR 27
I can't recall the status of this, etc. See: #27
1 parent 1302542 commit cd94545

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

simplenote/simplenote.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,17 @@ def authenticate(self, user, password):
7777
try:
7878
res = urllib2.urlopen(request).read()
7979
token = json.loads(res.decode('utf-8'))["access_token"]
80-
except (HTTPError, BadStatusLine):
80+
except HTTPError as error:
81+
if error.code == 401:
82+
raise SimplenoteLoginFailed('Login to Simplenote API failed! Check email address and password.')
83+
else:
84+
raise SimplenoteLoginFailed('Login to Simplenote API failed!')
85+
except BadStatusLine:
8186
raise SimplenoteLoginFailed('Login to Simplenote API failed!')
8287
except IOError: # no connection exception
83-
token = None
88+
raise SimplenoteLoginFailed('We appear to be offline')
89+
# Don't want to return "None" since that's potentially confusing so fail hard
90+
raise
8491
return token
8592

8693
def get_token(self):

0 commit comments

Comments
 (0)