lib/amqp/client/errors.rb in amqp-client-1.0.1 vs lib/amqp/client/errors.rb in amqp-client-1.0.2
- old
+ new
@@ -30,17 +30,34 @@
def initialize(class_id, method_id)
super "Unsupported class/method: #{class_id} #{method_id}"
end
end
+ # Depending on close level a ConnectionClosed or ChannelClosed error is returned
+ class Closed < Error
+ def self.new(id, level, code, reason, classid = 0, methodid = 0)
+ case level
+ when :connection
+ ConnectionClosed.new(code, reason, classid, methodid)
+ when :channel
+ ChannelClosed.new(id, code, reason, classid, methodid)
+ else raise ArgumentError, "invalid level '#{level}'"
+ end
+ end
+ end
+
# Raised if channel is already closed
class ChannelClosed < Error
def initialize(id, code, reason, classid = 0, methodid = 0)
super "Channel[#{id}] closed (#{code}) #{reason} (#{classid}/#{methodid})"
end
end
# Raised if connection is unexpectedly closed
- class ConnectionClosed < Error; end
+ class ConnectionClosed < Error
+ def initialize(code, reason, classid = 0, methodid = 0)
+ super "Connection closed (#{code}) #{reason} (#{classid}/#{methodid})"
+ end
+ end
end
end
end