#627: Obj-C exception raised within a rescue block are not catched ----------------------------------------+----------------------------------- Reporter: martinlagardette@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: rescue exception ----------------------------------------+----------------------------------- This file: {{{ #!ruby # test.rb begin begin raise rescue NSString.stringWithCString(nil) end rescue puts "rescued" end }}} Will produce the following: {{{ #!sh $> macruby /tmp/test.rb uncaught Objective-C/C++ exception... 2010-03-01 22:45:58.926 macruby[30392:903] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSString stringWithCString:]: NULL cString' *** Call stack at first throw: ( 0 CoreFoundation 0x00007fff84f80444 __exceptionPreprocess + 180 1 libobjc.A.dylib 0x00007fff84db80f3 objc_exception_throw + 45 2 CoreFoundation 0x00007fff84f80267 +[NSException raise:format:arguments:] + 103 3 CoreFoundation 0x00007fff84f801f4 +[NSException raise:format:] + 148 4 Foundation 0x00007fff87f704ed +[NSString stringWithCString:] + 80 5 ??? 0x0000000101040385 0x0 + 4312007557 6 libmacruby.dylib 0x0000000100174130 rb_vm_dispatch + 2688 7 ??? 0x000000010104015d 0x0 + 4312007005 8 libmacruby.dylib 0x0000000100184ebf rb_vm_run + 351 9 libmacruby.dylib 0x0000000100046459 ruby_run_node + 73 10 macruby 0x0000000100000d28 main + 152 11 macruby 0x0000000100000c88 start + 52 12 ??? 0x0000000000000002 0x0 + 2 ) terminate called after throwing an instance of 'NSException' Abort trap }}} However, using pure Ruby exceptions works without issue: {{{ #!ruby # test2.rb begin begin raise rescue raise end rescue puts "rescued" end }}} {{{ #!sh $> macruby /tmp/test2.rb rescued }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/627> MacRuby <http://macruby.org/>