Skip to content

Commit

Permalink
Merge pull request #15 from seanv507/druid_error_output
Browse files Browse the repository at this point in the history
report druid error
  • Loading branch information
fjy committed Sep 15, 2014
2 parents f959c70 + 93b65be commit a71e90b
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 @@ -118,8 +118,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 a71e90b

Please sign in to comment.