Catching runtime exceptions from callbacks

Hello,

I am currently integrating Ruby (1.8.6) inside an application. Until
now, I had no impossible problem although the API documentation is a
bit poor.

I use rb_load_protect to load a startup script file that contains some
callbacks like this :
Events.onChar { |char|
print(“char:#{char}”);
}
If there is an error while loading the file, I can catch it and get
the backtrace and everything I want because it’s inside protect(). But
if I use for example raise inside the callback, my program stops due
to a C++ runtime exception (here it’s not inside protect() anymore
because rb_load_protect returns after the file has been loaded).

I don’t know if it is possible but I would like to be able to also
catch RuntimeError (and all others) in my C++ code.
Thanks.

Remi Gillig.