Skip to content

Commit 6a7d438

Browse files
committed
Always raise TransportError with two params.
Fixes elastic#44, thanks brianz!
1 parent c4f7cb6 commit 6a7d438

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

elasticsearch/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def info(self):
3232
return self.args[2]
3333

3434
def __str__(self):
35-
return 'TransportError(%d, %r)' % (self.status_code, self.error)
35+
return 'TransportError(%s, %r)' % (self.status_code, self.error)
3636

3737

3838
class ConnectionError(TransportError):

elasticsearch/transport.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def sniff_hosts(self):
175175
except (ConnectionError, SerializationError):
176176
pass
177177
else:
178-
raise TransportError("Enable to sniff hosts.")
178+
raise TransportError("N/A", "Enable to sniff hosts.")
179179
except:
180180
# keep the previous value on error
181181
self.last_sniff = previous_sniff
@@ -198,7 +198,7 @@ def sniff_hosts(self):
198198
# we weren't able to get any nodes, maybe using an incompatible
199199
# transport_schema or host_info_callback blocked all - raise error.
200200
if not hosts:
201-
raise TransportError("Enable to sniff hosts - no viable hosts found.")
201+
raise TransportError("N/A", "Enable to sniff hosts - no viable hosts found.")
202202

203203
self.set_connections(hosts)
204204

0 commit comments

Comments
 (0)