Skip to content

Commit

Permalink
Correctly construct exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Klishin committed Dec 6, 2012
1 parent 838a185 commit e87d450
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/bunny/transport.rb
Expand Up @@ -71,7 +71,14 @@ def write(*args)
end
rescue Errno::EPIPE, Errno::EAGAIN, Bunny::ClientTimeout, IOError => e
close
raise Bunny::ConnectionError.new(e.message, @host, @port)

m = case e
when String then
e
when Exception then
e.message
end
raise Bunny::ConnectionError.new(m, @host, @port)
end
end
alias send_raw write
Expand Down

1 comment on commit e87d450

@markiz
Copy link

@markiz markiz commented on e87d450 Dec 6, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way you can have a rescue block with something other than an Exception object?

Please sign in to comment.