Exception propagation in wxruby

Hi all,

i don’t know if it’s a bug but at least, for me, incomprehensible.

try this code (plain ruby):

module A
class MyException < StandardError; end
def raise_ex
raise MyException, “details…”
rescue Exception => ex
puts “inside module A #{ex.class}”
raise
end
end

class Test
include A
def call_test
raise_ex
rescue Exception => ex
puts “inside class Test #{ex.class}”
end
end

Test.new.call_test

i get this…

inside module A A::MyException
inside class Test A::MyException

…as expected.

try this wxruby code:

begin
require ‘rubygems’
rescue LoadError
end
require ‘wx’

include Wx

module A
class MyException < StandardError; end
def raise_ex
raise MyException, “details…”
rescue Exception => ex
puts “inside module A #{ex.class}”
raise
end
end

class MyFrame < Frame
include A

def initialize
    super(nil, -1, "Raise Exception demonstration",
        DEFAULT_POSITION, Size.new(350,200), DEFAULT_FRAME_STYLE)
    panel = Panel.new(self, -1)

    button = Button.new(panel, -1, "Raise exception", 

Point.new(15,15))
evt_button( button.get_id ) { on_raise_exception }
evt_close { | e | on_close_window(e) }
end

def on_raise_exception
    raise_ex
  rescue Exception => ex
    puts "inside class MyFrame #{ex.class}"
end

def on_close_window(event)
  event.skip
end

end

class MyApp < App
def on_init
begin
main = MyFrame.new
main.show
rescue Exception => e
exit(1)
end
end

end

MyApp.new.main_loop

i get this…

inside module A ArgumentError # totally wrong error type

and even worse it doesn’t propagate.

Tested on ruby 1.8.6/1.9.1, wxruby 2.0.0/2.0.1 x86-mswin32/x86-mingw32

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs