do not crash if there are php errors before json

This commit is contained in:
Romain Bignon 2012-01-21 17:54:17 +01:00
commit b10f21334b

View file

@ -105,13 +105,14 @@ class AuMBrowser(BaseBrowser):
A=action, A=action,
P=parameter, P=parameter,
O='json') O='json')
buf = self.openurl(url, data) buf = self.openurl(url, data).read()
try: try:
r = json.load(buf) r = json.loads(buf[buf.find('{'):])
except ValueError: except ValueError:
buf.seek(0) raise ValueError(buf)
raise ValueError(buf.read())
#pprint(r)
if 'errors' in r and r['errors'] != '0' and len(r['errors']) > 0: if 'errors' in r and r['errors'] != '0' and len(r['errors']) > 0:
code = r['errors'][0] code = r['errors'][0]