Topic: What is extension of ruby Exception class object in c?

static VALUE myMethod(VALUE self, VALUE exc)
{   
          int a = TYPE(exc);
          printf(" %d ", a );
          // Some process on exc
}
void Init_myRuby()
{
    VALUE mRuby = rb_define_module("myRuby");
     VALUE mException = rb_define_class_under(mRuby, "Exception", rb_eRuntimeError);
     rb_define_singleton_method(mRuby, "myMethod", myMethod, 4);
}

Following is the code of ruby client script,

require 'myRuby'
def raiseExc()
    exception = myRuby::Exception.new("status","lasterror","function()","Calling some")
    myRuby::myMethod(exception, "Exception message: %s, Exception object %d", "Hi from Exception", 100)
end

raiseExc()

Last edited by salunke09 (2011-09-14 06:08:46)