Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #89 from gdb/master

Improve error handling capabilities for single-threaded applications
  • Loading branch information...
commit be122a2c22424106fd0aadf56b88c4c36f69e2a9 2 parents 5e39924 + 09fef22
Michael Klishin authored
View
9 lib/bunny/exceptions.rb
@@ -136,4 +136,13 @@ class InvalidCommand < ConnectionLevelException
class UnexpectedFrame < ConnectionLevelException
end
+
+ class NetworkErrorWrapper < StandardError
+ attr_reader :other
+
+ def initialize(other)
+ super(other.message)
+ @other = other
+ end
+ end
end
View
4 lib/bunny/session.rb
@@ -263,7 +263,7 @@ def handle_frame(ch_number, method)
@event_loop = nil
@transport.close
- rescue Exception => e
+ rescue StandardError => e
puts e.class.name
puts e.message
puts e.backtrace
@@ -309,6 +309,8 @@ def handle_frameset(ch_number, frames)
end
def handle_network_failure(exception)
+ raise NetworkErrorWrapper.new(exception) unless @threaded
+
if !recovering_from_network_failure?
@recovering_from_network_failure = true
if recoverable_network_failure?(exception)
View
2  lib/bunny/transport.rb
@@ -175,7 +175,7 @@ def initialize_socket
@socket.post_connection_check(host) if @verify_ssl
@socket
end
- rescue Exception => e
+ rescue StandardError, ConnectionTimeout => e
@status = :not_connected
raise Bunny::TCPConnectionFailed.new(e, self.hostname, self.port)
end
Please sign in to comment.
Something went wrong with that request. Please try again.