lib/bunny/exceptions.rb in bunny-1.4.1 vs lib/bunny/exceptions.rb in bunny-1.5.0.pre1
- old
+ new
@@ -2,10 +2,16 @@
# Base class for all Bunny exceptions
# @api public
class Exception < ::StandardError
end
+ class HostListDepleted < Exception
+ def initialize
+ super("No more hosts to try in the supplied list of hosts")
+ end
+ end
+
# Indicates a network failure. If automatic network
# recovery mode is enabled, these will be typically handled
# by the client itself.
#
# @api public
@@ -52,11 +58,10 @@
@connection = connection
@connection_close = connection_close
end
end
-
# Raised when TCP connection to RabbitMQ fails because of an unresolved
# hostname, connectivity problem, etc
class TCPConnectionFailed < Exception
attr_reader :hostname, :port
@@ -65,10 +70,20 @@
when String then
e
when Exception then
e.message
end
- super("Could not establish TCP connection to #{hostname}:#{port}: #{m}")
+ if hostname && port
+ super("Could not establish TCP connection to #{hostname}:#{port}: #{m}")
+ else
+ super(m)
+ end
+ end
+ end
+
+ class TCPConnectionFailedForAllHosts < TCPConnectionFailed
+ def initialize
+ super("Could not establish TCP connection to any of the configured hosts", nil, nil)
end
end
# Raised when a frame is sent over an already closed connection
class ConnectionClosedError < Exception