Skip to content
This repository was archived by the owner on Oct 30, 2018. It is now read-only.

Commit 6fe8546

Browse files
committed
Merge pull request #8 from karma0/errorhandling
Report output from API on error.
2 parents c97a335 + 1c4401e commit 6fe8546

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

alchemyapi.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,10 +762,17 @@ def __analyze(self, endpoint, params, post_data=bytearray()):
762762

763763
post_url = AlchemyAPI.BASE_URL + endpoint + '?' + urlencode(params).encode('utf-8');
764764

765+
results = ""
765766
try:
766767
results = self.s.post(url=post_url, data=post_data)
767-
return results.json()
768768
except Exception as e:
769769
print(e)
770770
return { 'status':'ERROR', 'statusInfo':'network-error' }
771+
try:
772+
return results.json()
773+
except Exception as e:
774+
if results != "":
775+
print(results)
776+
print(e)
777+
return { 'status':'ERROR', 'statusInfo':'parse-error' }
771778

0 commit comments

Comments
 (0)