Exception not caught / require BUG

Discussion in 'Ruby' started by Lothar Scholz, Feb 21, 2004.

  1. Hello,

    I found that the following exception does not raise an exception
    but kills the ruby interpreter.

    def test_traceback()
    begin
    require "Socket"
    rescue => detail
    print "Not available"
    end
    end


    it works when i require "socket" instead of the non existing "Socket".
    In the latter case i only get:

    c:/ruby/lib/ruby/1.8/i386-mswin32/Socket.so: 127: The specified procedure could not be found. - Init_Socket (LoadError)
    c:/ruby/lib/ruby/1.8/i386-mswin32/Socket.so from common/ruby/arachno_traceback.rb:25:in `test_traceback'
    from common/ruby/arachno_traceback.rb:45

    But since the file does not exist the error message about a not found
    procedure is also wrong.
     
    Lothar Scholz, Feb 21, 2004
    #1
    1. Advertisements

  2. Lothar Scholz

    ts Guest

    L> I found that the following exception does not raise an exception
    L> but kills the ruby interpreter.

    normal, LoadError don't inherit from StandardError

    svg% ruby -e 'p LoadError < StandardError'
    false
    svg%

    svg% ruby -e 'p LoadError < ScriptError'
    true
    svg%

    L> def test_traceback()
    L> begin
    L> require "Socket"
    L> rescue => detail
    L> print "Not available"
    L> end
    L> end

    Your rescue is for StandardError only

    L> c:/ruby/lib/ruby/1.8/i386-mswin32/Socket.so: 127: The specified
    L> procedure could not be found. - Init_Socket (LoadError)
    L> c:/ruby/lib/ruby/1.8/i386-mswin32/Socket.so from
    L> common/ruby/arachno_traceback.rb:25:in `test_traceback'
    L> from common/ruby/arachno_traceback.rb:45

    L> But since the file does not exist the error message about a not found
    L> procedure is also wrong.

    You probably work with a system which don't make the difference between
    the file Socket.so and socket.so and the error is right

    Init_Socket is not defined in socket.so


    Guy Decoux
     
    ts, Feb 21, 2004
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.