From: "Iñaki Baz Castillo" Date: 2012-05-02T18:17:53+09:00 Subject: rb_errinfo() "captures" more than exceptions, but also Interrupt and SystemExit Hi, my Ruby C extension use rb_protect() to rescue Ruby errors in the Ruby blocks provided by the high user. Basically, I run the user provided Ruby block as follows: ------------------------------- rb_protect(wrapper_rb_funcall_0, block, &exception); if (exception) { // rb_errinfo() gives the current exception object in this thread. rb_funcall(mMyModule, id_manage_exception, 1, rb_errinfo()); // Dissable the current thread exception. rb_set_errinfo(Qnil); } --------------------------------- The problem is that rb_errinfo() captures not just "normal" exceptions (RuntimeError, StandardError...), but also Interrupt or SystemExit. So if the Ruby code calls exit() then that is "rescued" by my library, which is of course wrong. So maybe I need to check the object returned by rb_errinfo() prior to "rescuing" it. In short, I need to know which exact exceptions are captured by the standard "rescue" (without giving it an specific exception class): begin SOME_ERROR rescue => e puts "Exception #{e.class} rescued" end AFAIK those exceptions are "StandardError" and the classes inheriting from it. So I just need to check whether the VALUE object returned by rb_errinfo() inherits from rb_eStandardError. Am I right? Thanks a lot. -- Iñaki Baz Castillo