From: Daniel Berger Date: 2007-02-10T01:45:54+09:00 Subject: Re: Help begin/rescue/ensure On Feb 9, 2:06 am, Brian Candler wrote: > On Fri, Feb 09, 2007 at 02:20:30PM +0900, S Kanakakorn wrote: > > require 'rubygems' > > require 'net/ssh' > > > begin > > session = Net::SSH.start('aaaa-lnx', :password=>'xyz', > > :username=>'root',:timeout=>5) > > rescue > > puts 'cannot connect ' > > ensure > > puts 'reach ensure point' > > end > > puts 'at last' > ... > > What did I do wrong ? > > A bare "rescue" doesn't catch all exceptions, only those which are > subclasses of StandardError. Change to: > > rescue Exception Given how often this issue appears on the mailing list, I'm beginning to think that a bare rescue should just rescue Exception. That seems to be what most people expect it to do. Is there a downside to this idea? Dan