do not crash if there are php errors before json
This commit is contained in:
parent
65169a8a8d
commit
b10f21334b
1 changed files with 5 additions and 4 deletions
|
|
@ -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]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue