Dynamic requires

B

belorion

Note: parts of this message were removed by the gateway to make it a legal Usenet post.

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
 
D

dblack

Hi --

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.

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

--
Upcoming training by David A. Black/Ruby Power and Light, LLC:
* Advancing With Rails, Edison, NJ, November 6-9
* Advancing With Rails, Berlin, Germany, November 19-22
* Intro to Rails, London, UK, December 3-6 (by Skills Matter)
See http://www.rubypal.com for details!
 
B

belorion

Note: parts of this message were removed by the gateway to make it a legal Usenet post.

I did not know that! (obviously).

Much appreciated.

Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,836
Latest member
login dogas

Latest Threads

Top