Dynamic requires

I don’t want to go into to much boring detail as to why I am trying to
do
this… but why doesn’t this work?

begin
require ‘foo’
rescue
class Foo
end
end

Instead of rescuing the error (when ‘foo’ is not found), it still gets
thrown.

regards,
Matt

Hi –

On Sun, 4 Nov 2007, Belorion wrote:

Instead of rescuing the error (when ‘foo’ is not found), it still gets
thrown.

It’s because the bare “rescue” only rescues errors that are
descendants of StandardError. Otherwise you have to specify the ones
you want:

rescue LoadError

David

I did not know that! (obviously).

Much appreciated.

Matt