static void errat_setter(VALUE val, ID id, VALUE *var) { VALUE err = get_errinfo(); if (NIL_P(err)) { rb_raise(rb_eArgError, "$! not set"); } set_backtrace(err, val); }
static VALUE errat_getter(ID id) { VALUE err = get_errinfo(); if (!NIL_P(err)) { return get_backtrace(err); } else { return Qnil; } }
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 */ }
/* * call-seq: * raise * raise(string) * raise(exception [, string [, array]]) * fail * fail(string) * fail(exception [, string [, array]]) * * With no arguments, raises the exception in <code>$!</code> or raises * a <code>RuntimeError</code> if <code>$!</code> is +nil+. * With a single +String+ argument, raises a * +RuntimeError+ with the string as a message. Otherwise, * the first parameter should be the name of an +Exception+ * class (or an object that returns an +Exception+ object when sent * an +exception+ message). The optional second parameter sets the * message associated with the exception, and the third parameter is an * array of callback information. Exceptions are caught by the * +rescue+ clause of <code>begin...end</code> blocks. * * raise "Failed to create socket" * raise ArgumentError, "No parameters", caller */ mrb_value mrb_f_raise(mrb_state *mrb, mrb_value self) { mrb_value err; mrb_value *argv; int argc; mrb_get_args(mrb, "*", &argv, &argc); if (argc == 0) { err = get_errinfo(mrb); if (!mrb_nil_p(err)) { argc = 1; argv[0] = err; } } mrb_exc_raise(mrb, mrb_make_exception(mrb, argc, argv)); return mrb_nil_value(); /* not reached */ }
VALUE rb_rubylevel_errinfo(void) { return get_errinfo(); }
static VALUE errinfo_getter(ID id) { return get_errinfo(); }