Catching runtime exceptions from callbacks


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|
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.

Remi Gillig.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs