IRB.load_modules Bug?

C

Curt Sampson

irb/init.rb contains the following code:

def IRB.load_modules
for m in @CONF[:LOAD_MODULES]
begin
require m
rescue
print $@[0], ":", $!.class, ": ", $!, "\n"
end
end
end

Unfortunately, that rescue does not appear to catch LoadError, at least
on my system (ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-netbsdelf]).
Is it supposed to?

cjs
 
M

MonkeeSage

irb/init.rb contains the following code:

def IRB.load_modules
for m in @CONF[:LOAD_MODULES]
begin
require m
rescue
print $@[0], ":", $!.class, ": ", $!, "\n"
end
end
end

Unfortunately, that rescue does not appear to catch LoadError, at least
on my system (ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-netbsdelf]).
Is it supposed to?

cjs

I'm not sure of the intended behavior, but in 1.9 it has...

rescue # StandardError, ScriptError

....which makes me think that LoadError is intentionally not rescued.

I've put the following in my .ircrb...

def IRB.load_modules
errors = []
for m in @CONF[:LOAD_MODULES]
begin
require m
rescue # StandardError, ScriptError
print $@[0], ":", $!.class, ": ", $!, "\n"
rescue LoadError => e
errors << "\n*** #{e.message}"
end
end
puts "#{errors.join('')}\n\n" unless errors.empty?
end

Regards,
Jordan
 

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,871
Messages
2,569,919
Members
46,171
Latest member
A.N.Omalum

Latest Threads

Top