diff --git a/elasticsearch/connection/base.py b/elasticsearch/connection/base.py index aa2ce332..5d254555 100644 --- a/elasticsearch/connection/base.py +++ b/elasticsearch/connection/base.py @@ -95,6 +95,8 @@ class Connection(object): try: additional_info = json.loads(raw_data) error_message = additional_info.get('error', error_message) + if isinstance(error_message, dict) and 'type' in error_message: + error_message = error_message['type'] except: # we don't care what went wrong pass diff --git a/test_elasticsearch/test_server/test_common.py b/test_elasticsearch/test_server/test_common.py index 5db653b0..c6386489 100644 --- a/test_elasticsearch/test_server/test_common.py +++ b/test_elasticsearch/test_server/test_common.py @@ -168,7 +168,7 @@ class YamlTestCase(ElasticsearchTestCase): if catch in CATCH_CODES: self.assertEquals(CATCH_CODES[catch], exception.status_code) elif catch[0] == '/' and catch[-1] == '/': - self.assertTrue(re.search(catch[1:-1], exception.error)) + self.assertTrue(re.search(catch[1:-1], repr(exception.info))) self.last_response = exception.info def run_gt(self, action):