Skip to content
Browse files

if the HTTP response is 401 throw an Unauthorized exception. This hel…

…ps to distinguish authorization problems from other problems (i.e. requesting nonexisting boards, lists etc.)
  • Loading branch information...
1 parent 864a95b commit 41735cf698dd69404172c54d48dd2b4713c1dbfd @dirk-olmes dirk-olmes committed Jun 6, 2012
Showing with 5 additions and 0 deletions.
  1. +5 −0 trello/__init__.py
View
5 trello/__init__.py
@@ -19,6 +19,9 @@ def __init__(self, msg):
def __str__(self):
return "Resource unavailable: %s" % (self._msg)
+class Unauthorized(ResourceUnavailable):
+ pass
+
class TrelloClient(object):
""" Base class for Trello API access """
@@ -127,6 +130,8 @@ def fetch_json(
body = json.dumps(post_args))
# error checking
+ if response.status == 401:
+ raise Unauthorized(url)
if response.status != 200:
raise ResourceUnavailable(url)
return json.loads(content)

0 comments on commit 41735cf

Please sign in to comment.
Something went wrong with that request. Please try again.