From: "Iñaki Baz Castillo" Date: 2012-05-02T18:58:54+09:00 Subject: Re: rb_errinfo() "captures" more than exceptions, but also Interrupt and SystemExit 2012/5/2 Iñaki Baz Castillo : > Hi, I got it at 80%, just a single issue remains. This is the code > that tries to "imitate" the classic "begin-rescue-end" at C level: > > >  rb_protect(my_wrapper_rb_funcall_0, block, &exception); > >  if (exception)  { >    // rb_errinfo() gives the current exception object in this thread. >    VALUE exception = rb_errinfo(); > >    if (rb_obj_is_kind_of(exception, rb_eStandardError) == Qtrue) { >      rb_funcall(mMyModule, rb_intern("manage_exception", 1, exception); >      // Dissable the current thread exception. >      rb_set_errinfo(Qnil); >    } >    else { >      // TODO: It's not a public Ruby function !!! >      //rb_f_raise(0, NULL); >    } >  } > > > The only I need is to find how to raise the produced exception when > it's not a StandardError. In ruby land I just need to call "raise" > (with no arguments). In C land, rb_f_raise() is the C function used by > "raise", but it's not public !! > > So what is the alternative? Note that exception variable holds the > exception instance, not a class, so I cannot use rb_raise. Sorry, my fault: exception INT variable holds the integer given to rb_protect, so if it's != 0 then I just need to do rb_jump_tag(integer). :) -- Iñaki Baz Castillo