Beispiel #1
0
static VALUE
rb_mg_raise(int argc, VALUE *argv, VALUE self)
{
    // -----------------------------------------------------------
    //  Get a reference to the Exception object
    // -----------------------------------------------------------
    VALUE e = rb_make_exception(argc, argv);

    if (NIL_P(e)) {
      // get whatever is in $!. I'm sure this is slow
      e = rb_eval_string("$!");
      // what I'd like to use really like to use
//       e = rb_rubylevel_errinfo(); // internal ruby call, yet necessary
    }

    if (NIL_P(e)) {
      e = rb_exc_new(rb_eRuntimeError, 0, 0);
    }

    // -----------------------------------------------------------
    //  With the Exception in place, add the recoveries
    // -----------------------------------------------------------
    rb_funcall(mKernel, id___process_exception_from_raise__, 1, e);

    // -----------------------------------------------------------
    //  raise the exception
    // -----------------------------------------------------------
    rb_exc_raise(e);

//     UNREACHABLE;
}
Beispiel #2
0
static VALUE
rb_f_raise(VALUE klass, SEL sel, int argc, VALUE *argv)
{
    VALUE err;
    if (argc == 0) {
	err = get_errinfo();
	if (!NIL_P(err)) {
	    argc = 1;
	    argv = &err;
	}
    }
    rb_vm_raise(rb_make_exception(argc, argv));
    return Qnil;		/* not reached */
}
Beispiel #3
0
static VALUE
thread_raise_m(VALUE self, SEL sel, int argc, VALUE *argv)
{
    VALUE exc = rb_make_exception(argc, argv);

    rb_vm_thread_t *t = GetThreadPtr(self);

    if (t->thread == pthread_self()) {
	rb_exc_raise(exc);
    }
    else if (t->status != THREAD_DEAD) {
	rb_vm_thread_raise(t, exc);
    }

    return Qnil;
}