Better exception representation
This commit is contained in:
@@ -49,7 +49,13 @@ class TransportError(ElasticsearchException):
|
||||
return self.args[2]
|
||||
|
||||
def __str__(self):
|
||||
return 'TransportError(%s, %r)' % (self.status_code, self.error)
|
||||
cause = ''
|
||||
try:
|
||||
if self.info:
|
||||
cause = ', %r' % self.info['error']['root_cause'][0]['reason']
|
||||
except LookupError:
|
||||
pass
|
||||
return 'TransportError(%s, %r%s)' % (self.status_code, self.error, cause)
|
||||
|
||||
|
||||
class ConnectionError(TransportError):
|
||||
|
||||
@@ -14,7 +14,7 @@ class FailingBulkClient(object):
|
||||
def bulk(self, *args, **kwargs):
|
||||
self._called += 1
|
||||
if self._called == self._fail_at:
|
||||
raise TransportError(599, "Error!", "INFO")
|
||||
raise TransportError(599, "Error!", {})
|
||||
return self.client.bulk(*args, **kwargs)
|
||||
|
||||
class TestStreamingBulk(ElasticsearchTestCase):
|
||||
|
||||
Reference in New Issue
Block a user