Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed update comment bug, added Exceptions.

  • Loading branch information...
commit 95ac5f1f3f5528e3f211f4ccbfca3355e2ddcc7a 1 parent f4e2fdd
@bartek authored
Showing with 15 additions and 5 deletions.
  1. +15 −5 plancast.py
View
20 plancast.py
@@ -14,10 +14,20 @@
class PlancastError(Exception):
def __init__(self, data):
- self.data = data
+ errors = {
+ 401: UnauthorizedError,
+ 403: RateLimitExceeded,
+ 404: NotFound,
+ 500: ServerError,
+ }
+ raise errors.get(data.code, UnknownError)(data)
+
+class UnauthorizedError(Exception): pass
+class RateLimitExceeded(Exception): pass
+class NotFound(Exception): pass
+class ServerError(Exception): pass
+class UnknownError(Exception): pass
-class UnauthorizedError(PlancastError):
- pass
class Plancast(object):
def __init__(self, username=None, password=None, version="02", format=".json"):
@@ -253,7 +263,7 @@ def update_comment(self, query):
@param: `plan_id` or `attendance_id` - Base 36 ID of plan or existing attendance for a plan.
@example:
plan.update_comment({
- 'comment': 'Hello, this is a cool.',
+ 'content': 'Hello, this is a cool.',
'plan_id': '289a',
})
"""
@@ -283,6 +293,6 @@ def get(self, endpoint, query=None):
try:
handle = json.loads(urllib2.urlopen(req).read())
except urllib2.HTTPError, e:
- raise Exception(e)
+ raise PlancastError(e)
return handle
Please sign in to comment.
Something went wrong with that request. Please try again.