Re: [Fxruby-users] Re: catching exceptions in event handlers
Status: Inactive
Brought to you by:
lyle
From: Lyle J. <jl...@cf...> - 2003-07-23 14:17:59
|
Aaron Schrab wrote: > At 15:40 +0100 23 Jul 2003, Emmanuel Touzery <emm...@wa...> wrote: >> C:\programs\glossary\test>ruby test.rb >> test.rb:38:in `onCmdOpen': undefined local variable or method `pouf' for >> #<Gloss >> aryMainWindow:0x52d3c78> (NameError) >> from test.rb:61:in `run' >> from test.rb:61 > > NameError exceptions don't get caught by a bare rescue since that's > equivalent to "rescue StandardError". If you truly want to catch all > exceptions you need to use "rescue Exception". Yep, Aaron beat me to it ;) When I went back and tried running Emmanuel's program I got different results under Ruby version 1.6.8 and 1.8.0. It turns out that for Ruby 1.6, the NameError exception is derived from ScriptError and not StandardError, so the plain 'rescue' won't catch it. In Ruby 1.8.0, which I originally used to run the program, NameError is now derived from StandardError, and so the plain 'rescue' /does/ catch it. So, in summary, FXRuby does appear to be doing the right thing as far as passing Ruby exceptions up the call chain. |