From: Tomas Matousek Date: 2009-08-05T10:20:39+09:00 Subject: [ruby-core:24767] [Bug #1886] Strange exception thrown when Exception#new is overridden and returns a non-Exception Bug #1886: Strange exception thrown when Exception#new is overridden and returns a non-Exception http://redmine.ruby-lang.org/issues/show/1886 Author: Tomas Matousek Status: Open, Priority: Normal ruby -v: ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-mswin32] class ZeroDivisionError def self.new(message) puts 'new ZeroDivError' 'not an exception' end end module Any def self.===(other) puts "?#{other.inspect}" true end end begin 1/0 rescue Exception, Any puts "rescue" p $! ensure puts "ensure" end puts 'Done' ===== The output is: new ZeroDivError ensure This means that if a non-Exception is returned from the new method above, the stack is magically unwound ignoring all rescue clauses (=== is not called) and no error message is displayed at all. The same behavior can be observed in both: ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32] ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-mswin32] ---------------------------------------- http://redmine.ruby-lang.org