diff --git a/pydruid/client.py b/pydruid/client.py index 8d7afbdf..922880b7 100755 --- a/pydruid/client.py +++ b/pydruid/client.py @@ -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