Exceptions with Swig 1 void foo(int x); 2 3 %except(ruby) { 4 RUBY_TRY { 5 $function 6 } catch(std::bad_alloc & ex) { 7 RUBY_RETHROW(rb_exc_new2( 8 rb_eRuntimeError, 9 "failed to allocate memory")); 10 } RUBY_CATCH 11 }