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
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
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!