projects
/
mw
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4a2642f
)
Raise exception on API errors
author
Ian Weller
<ian@ianweller.org>
Sun, 14 Mar 2010 06:56:35 +0000
(
00:56
-0600)
committer
Ian Weller
<ian@ianweller.org>
Sun, 14 Mar 2010 06:56:35 +0000
(
00:56
-0600)
src/mw/api.py
patch
|
blob
|
history
diff --git
a/src/mw/api.py
b/src/mw/api.py
index 88dee80e2371e640253ce81658901ebc692acd5e..09467824b1e766695e3a58bb0a5b38cc79351ae7 100644
(file)
--- a/
src/mw/api.py
+++ b/
src/mw/api.py
@@
-44,7
+44,10
@@
class API(object):
data = gzipper.read()
else:
data = response.read()
data = gzipper.read()
else:
data = response.read()
- return json.loads(data)
+ the_data = json.loads(data)
+ if 'error' in the_data.keys():
+ raise APIError(the_data['error']['info'])
+ return
def limits(self, low, high):
if self._high_limits == None:
def limits(self, low, high):
if self._high_limits == None:
@@
-59,6
+62,15
@@
class API(object):
return low
return low
+class APIError(Exception):
+
+ def __init__(self, info):
+ self.info = info
+
+ def __str__(self):
+ return self.info
+
+
def pagename_to_filename(name):
name = name.replace(' ', '_')
name = name.replace('/', '!')
def pagename_to_filename(name):
name = name.replace(' ', '_')
name = name.replace('/', '!')
Benjamin Mako Hill
||
Want to submit a patch?