Added api error handeling and updated docs

This commit is contained in:
Newmu
2014-09-12 13:12:25 -04:00
parent f1968cf342
commit d6cb1bf1d9
5 changed files with 35 additions and 11 deletions
+5 -1
View File
@@ -28,4 +28,8 @@ def language(text):
data_dict = json.dumps({'text': text})
response = requests.post("http://api.indico.io/language", data=data_dict, headers=JSON_HEADERS)
return json.loads(response.content)
response_dict = response.json()
if len(response_dict) < 2:
raise ValueError(response_dict.values()[0])
else:
return response_dict