Skip to content

Commit a2eab4c

Browse files
author
Xavier Grand
committed
Fix parsing error in case of httpCode != 2XX
1 parent d968782 commit a2eab4c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
CHANGELOG
22

3+
master
4+
* Fix potential parsing error in case of httpCode == 4XX
5+
36
2016-07-05 1.9.1
47
* Fix the `strategy` parameter of `mutliple_queries`
58
* Add the `forwardToSlaves` parameter of `set_settings`

algoliasearch/transport.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ def _session_req(self, host, path, meth, timeout, params, data):
8181

8282
if res.status_code // 100 == 4:
8383
message = 'HTTP Code: %d' % (res.status_code)
84-
j = res.json()
84+
try:
85+
j = res.json()
86+
except:
87+
j = { 'message': res.text}
8588
if j is not None and 'message' in j:
8689
message = j['message']
8790
raise AlgoliaException(message)

0 commit comments

Comments
 (0)