From: "David A. Black" Date: 2008-07-21T00:04:55+09:00 Subject: Re: Does "rescue" wihtour argument handle any kind of Exception or not? --1926193751-584292447-1216566614=:4982 Content-Type: MULTIPART/MIXED; BOUNDARY="1926193751-584292447-1216566614=:4982" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --1926193751-584292447-1216566614=:4982 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Hi -- On Mon, 21 Jul 2008, I=C3=B1aki Baz Castillo wrote: > El Domingo, 20 de Julio de 2008, Phlip escribi=C3=B3: >> Stefano Crocco wrote: >>>> Exception >>>> - StandardError >>>> - RuntimeError >>>> - ZeroDivisionError >>>> - ScriptError >>>> - SyntaxError >>>> - SystemExit >>>> - SignalException >>>> - Interrupt >>>> >>>> begin >>>> =09raise Interrupt >>>> rescue >>>> =09puts "rescued !!!" >>>> end >>> >>> For me, using ruby 1.8.7, patchlevel 22 on Gentoo Linux, your code work= s >>> as the article says, that is the exception is not being caught. >> >> Same with p22 on Ubuntu. (I think I compiled it, too.) >> >> Run p Interrupt.ancestors, and see if you get: >> >> [Interrupt, SignalException, Exception, Object, Kernel] > > ruby1.8 1.8.6.36-1ubuntu3.1 > > irb> p Interrupt.ancestors > [Interrupt, SignalException, Exception, Object, Wirble::Shortcuts, > PP::ObjectMixin, Kernel] > > > It's different! > > >> Also, put p $! into the rescue handler to see _what_ you rescued! > > ----------- > require 'timeout' > > begin > raise Interrupt > rescue > puts "rescued !!!" > puts $! > end > ---------- > > ~# ./test.rb > rescued !!! > wrong number of arguments (0 for 1) > > > =C2=BF? begin raise Interrupt rescue =3D> e puts "rescued !!!: #{e.class}" end It's ArgumentError in 1.8.6, and nothing (the rescue doesn't happen) in 1.9. David --=20 Rails training from David A. Black and Ruby Power and Light: Intro to Ruby on Rails July 21-24 Edison, NJ Advancing With Rails August 18-21 Edison, NJ See http://www.rubypal.com for details and updates! --1926193751-584292447-1216566614=:4982-- --1926193751-584292447-1216566614=:4982--