--- generator/ruby.ml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/generator/ruby.ml b/generator/ruby.ml index 97ccfdc..0f71ccc 100644 --- a/generator/ruby.ml +++ b/generator/ruby.ml @@ -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; } -- 2.7.4