Take action when an event handler raises an exception
mvz opened this issue · comments
Exceptions currently get silently ignored. This is confusing. Because there is no valid stack level to bubble up to, we should probably just print its message and continue. The other alternative is to print a stack trace and abort.
See mvz/gir_ffi-gtk#10.
See also ffi/ffi#141.
In most cases the error will be propagated to an enclosing Ruby method. It is not yet clear under what circumstances this does not happen.
The problem seems to occur only if the Ruby callback is called from inside a separate C thread. The situation is vaguely similar to how exceptions raised in Ruby threads are not propagated unless the thread is joined. I'm going to leave this unfixed and create an entry in the Wiki.
Wiki entry created: https://github.com/mvz/ruby-gir-ffi/wiki/Exceptions-in-callbacks
Maybe Thread.abort_on_exception = true
is the solution.
No, it's not.
Experimental support for this has been added to this gem and should be part of the 0.9.0 release.