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?
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?
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.