# Exception propagation in wxruby

**URL:** <https://www.ruby-forum.com/t/exception-propagation-in-wxruby/185449>\
**Category:** wxRuby\
**Created:** [March 20, 2010, 10:31am UTC](https://www.ruby-forum.com/t/exception-propagation-in-wxruby/185449 "2010-03-20T10:31:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![biospank](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@biospank](https://www.ruby-forum.com/u/biospank)\
**Post date:** [March 20, 2010, 10:31am UTC](https://www.ruby-forum.com/t/exception-propagation-in-wxruby/185449/1 "2010-03-20T10:31:13Z")

</div>

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
