From b1c8c6193560807e9f0e756dd1898b281076eea8 Mon Sep 17 00:00:00 2001 From: Daniel Lindsley Date: Tue, 3 Jan 2012 00:01:41 -0600 Subject: [PATCH] Better messages. --- pyelasticsearch.py | 4 ++-- tests.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyelasticsearch.py b/pyelasticsearch.py index d2ed35b..f2b39c1 100644 --- a/pyelasticsearch.py +++ b/pyelasticsearch.py @@ -371,7 +371,7 @@ def create_index(self, index, settings=None, quiet=True): except ElasticSearchError, e: if not quiet: raise - response = {"message": "Index '%s' already exists." % index} + response = {"message": "Create index '%s' errored: %s" % (index, e)} return response def delete_index(self, index, quiet=True): @@ -383,7 +383,7 @@ def delete_index(self, index, quiet=True): except ElasticSearchError, e: if not quiet: raise - response = {"message": "Index '%s' doesn't exist." % index} + response = {"message": "Delete index '%s' errored: %s" % (index, e)} return response def flush(self, indexes=['_all'], refresh=None): diff --git a/tests.py b/tests.py index a98db92..9fb4f97 100644 --- a/tests.py +++ b/tests.py @@ -88,7 +88,7 @@ def testCannotCreateExistingIndex(self): self.conn.create_index("another-index") result = self.conn.create_index("another-index") self.conn.delete_index("another-index") - self.assertEqual(result, {'message': "Index 'another-index' already exists."}) + self.assertEqual(result, {'message': "Create index 'another-index' errored: Non-OK status code returned (400) containing u'IndexAlreadyExistsException[[another-index] Already exists]'."}) self.assertRaises(ElasticSearchError, self.conn.delete_index, "another-index", quiet=False) def testPutMapping(self):