Quick question,

How do you handle exceptions in a ruby extension? I see rb_rescue, but it
don't see how I get at the exception object in func2.

VALUE rb_rescue(VALUE (*func1)(), void *arg1, VALUE (*func2)(), void *arg2)
Calls the function func1, with arg1 as the argument. If an exception occurs
during func1, it calls func2 with arg2 as the argument. The return value of
rb_rescue() is the return value from func1 if no exception occurs, from
func2 otherwise.


I want to catch a ruby exception and turn it into a .net exception, so the
code I need would look something like this

virtual System::Object *send(System::String *cmd, System::Object *array[]) {

    RUBYTRY {
        return marshalToDotNet(rb_apply(*_handle,
rb_intern(toStdString(cmd).c_str()),

marshalArrayFromDotNet(array)));
    } RUBYCATCH (RubyException ex) {
        throw new RubyDotNet::Exception(ex);
    }

}

What is the best way?

Thomas