ruby: Print exceptions thrown by event callbacks.

This commit is contained in:
Richard W.M. Jones
2016-06-07 20:52:04 +01:00
parent 35fa141522
commit 4d6899ee91

View File

@@ -404,15 +404,17 @@ event_callback_wrapper_wrapper (VALUE argvv)
return Qnil;
}
/* Callbacks aren't supposed to throw exceptions. We just print the
* exception on stderr and hope for the best.
*/
static VALUE
event_callback_handle_exception (VALUE not_used, VALUE exn)
{
/* Callbacks aren't supposed to throw exceptions. */
fprintf (stderr, \"libguestfs: exception in callback!\\n\");
volatile VALUE message;
/* XXX We could print the exception, but it's very difficult from
* a Ruby extension.
*/
message = rb_funcall (exn, rb_intern (\"to_s\"), 0);
fprintf (stderr, \"libguestfs: exception in callback: %%s\\n\",
StringValueCStr (message));
return Qnil;
}