From 93b65bea3c1e592e94d649a97fc1a60557091f31 Mon Sep 17 00:00:00 2001 From: Sean Violante Date: Mon, 15 Sep 2014 18:35:55 +0200 Subject: [PATCH] report druid error --- pydruid/client.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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