From 6a7d4389cdec4b70b216e1fb6a1402ca734773d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Honza=20Kr=C3=A1l?= Date: Thu, 6 Feb 2014 01:15:41 +0100 Subject: [PATCH] Always raise TransportError with two params. Fixes #44, thanks brianz! --- elasticsearch/exceptions.py | 2 +- elasticsearch/transport.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/elasticsearch/exceptions.py b/elasticsearch/exceptions.py index 8db34719..5f52578b 100644 --- a/elasticsearch/exceptions.py +++ b/elasticsearch/exceptions.py @@ -32,7 +32,7 @@ class TransportError(ElasticsearchException): return self.args[2] def __str__(self): - return 'TransportError(%d, %r)' % (self.status_code, self.error) + return 'TransportError(%s, %r)' % (self.status_code, self.error) class ConnectionError(TransportError): diff --git a/elasticsearch/transport.py b/elasticsearch/transport.py index 972675d5..b39ea43b 100644 --- a/elasticsearch/transport.py +++ b/elasticsearch/transport.py @@ -175,7 +175,7 @@ class Transport(object): except (ConnectionError, SerializationError): pass else: - raise TransportError("Enable to sniff hosts.") + raise TransportError("N/A", "Enable to sniff hosts.") except: # keep the previous value on error self.last_sniff = previous_sniff @@ -198,7 +198,7 @@ class Transport(object): # we weren't able to get any nodes, maybe using an incompatible # transport_schema or host_info_callback blocked all - raise error. if not hosts: - raise TransportError("Enable to sniff hosts - no viable hosts found.") + raise TransportError("N/A", "Enable to sniff hosts - no viable hosts found.") self.set_connections(hosts)