No Rescue from RubyGem's require__?

I have the latest version of RubyGems installed and I seem to be
getting an unexpected error b/c of it:

irb(main):001:0> begin
irb(main):002:1* require 'carat/functor'
irb(main):003:1> rescue
irb(main):004:1> class Functor
irb(main):005:2> def initialize(&func) ; @func = func ; end
irb(main):006:2> def method_missing(op, *args) ; @func.call(op,
*args) ; end
irb(main):007:2> end
irb(main):008:1> end
LoadError: No such file to load -- carat/functor
        from
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:18:in
`require__'
        from
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:18:in `require'
        from (irb):2

Shouldn't the rescue clause be picked up?

Thanks,
T.

Without rubygems:

begin
  require "nonesuch"
rescue
  puts "rescued!"
end
LoadError: No such file to load -- nonesuch
        from (irb):2:in `require'
        from (irb):2

you need to rescue LoadError:

require 'rubygems'
    ==>true
begin
  require "nonesuch"
rescue LoadError
  puts "rescued!"
end
rescued!
    ==>nil

cheers,
Mark

···

On 4/20/05, Trans <transfire@gmail.com> wrote:

I have the latest version of RubyGems installed and I seem to be
getting an unexpected error b/c of it:

irb(main):001:0> begin
irb(main):002:1* require 'carat/functor'
irb(main):003:1> rescue
irb(main):004:1> class Functor
irb(main):005:2> def initialize(&func) ; @func = func ; end
irb(main):006:2> def method_missing(op, *args) ; @func.call(op,
*args) ; end
irb(main):007:2> end
irb(main):008:1> end
LoadError: No such file to load -- carat/functor
        from
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:18:in
`require__'
        from
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:18:in `require'
        from (irb):2

Shouldn't the rescue clause be picked up?

Oh! I thought rescue without a specified error would catch all errors.
It must all StandardErrors then? Even so, catching the specific
LoadError is much better.
Thanks!

T.

Correct.

PGP.sig (194 Bytes)

···

On 20 Apr 2005, at 10:39, Trans wrote:

Oh! I thought rescue without a specified error would catch all errors.
It must all StandardErrors then?

--
Eric Hodel - drbrain@segment7.net - http://segment7.net
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04