Skip to content

Commit

Permalink
report druid error
Browse files Browse the repository at this point in the history
  • Loading branch information
seanv507 committed Sep 15, 2014
1 parent 52ff514 commit 93b65be
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pydruid/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,18 @@ def __post(self, query):
self.result_json = data
res.close()
except urllib2.HTTPError, e:
raise IOError('{0} \n Query is: {1}'.format(
e, json.dumps(self.query_dict, indent=4)))
err=None
if e.code==500:
# has Druid returned an error?
try:
err= json.loads(e.read())
except ValueError:
pass
else:
err= err.get('error',None)

raise IOError('{0} \n Druid Error: {1} \n Query is: {2}'.format(
e, err,json.dumps(self.query_dict, indent=4)))
else:
self.result = self.__parse()
return self.result
Expand Down

0 comments on commit 93b65be

Please sign in to comment.