From: Brian Candler Date: 2012-10-23T03:12:22+09:00 Subject: Re: Exception handelling in ruby ajay paswan wrote in post #1080695: > What is diffrence between: > > rescue => e > > and > > rescue Exception => e The first is equivalent to rescue StandardError => e Exception is the top level class. You usually don't want to catch this; it includes things like Interrupt (ctrl-C), NoMemoryError, SyntaxError etc. which really ought to be fatal. > For example: rescue ZeroDivisionError > catches an error by division by zero, how to know -the type of error > which is 'ZeroDivisionError' here. >> 1/0 ZeroDivisionError: divided by 0 from (irb):7:in `/' from (irb):7 >> ObjectSpace.each_object(Class).select { |e| e.ancestors.include? Exception } -- Posted via http://www.ruby-forum.com/.