From: Brian Candler Date: 2012-10-25T04:47:42+09:00 Subject: Re: Exception handelling in ruby ajay paswan wrote in post #1080767: > but I have seen that in the following two statements > > rescue => e > and > rescue Exception => e > > The 'execution expired' error is caught by second statement, but not > first statement.. WHY? Because the first is rescue StandardError => e and only catches those exceptions which are under StandardError. "execution expired" is probably Timeout::Error from timeout.rb. This is a subclass of Interrupt, which is not underneath StandardError. So to rescue it: require 'timeout' begin Timeout::timeout(5) { sleep(10) } rescue Timeout::Error puts "I had enough" end I strongly recommend you rescue exactly the exception you want, and not "Exception". -- Posted via http://www.ruby-forum.com/.