On 17/05/2012, at 9:59 AM, I=F1aki Baz Castillo wrote:

> Hi, using Ruby 1.9 I've realized that "rescue" traps more than
> StandardError exceptions, for example NoMemoryError:


Not for me it doesn't.



 irb
1.9.3p125 :001 > NoMemoryError.ancestors
 =3D> [NoMemoryError, Exception, Object, Kernel, BasicObject]=20
1.9.3p125 :002 >=20
1.9.3p125 :003 >   begin
1.9.3p125 :004 >      raise NoMemoryError, "NO MEMORY !!!"
1.9.3p125 :005?>   rescue
1.9.3p125 :006?>    puts "rescued"
1.9.3p125 :007?>   end
NoMemoryError: NO MEMORY !!!
	from (irb):4
	from /Users/henry/.rvm/rubies/ruby-1.9.3-p125/bin/irb:16:in =
`<main>'
1.9.3p125 :008 >=20



> But for example it does not trap ScriptError exceptions. So which
> exact exception classes does "rescue" trap? is it docummented
> somewhere? Unfortunately I am not able to find in Ruby sources where
> the definition of "rescue" is.

Google is your friend...

http://jpablobr.com/past/ruby-s-exception-hierarchy

Rescuing an Exception class will also rescue it's sub-classes. This =
doesn't work work for modules though, which would be really handy.

Henry