Method: Kernel#raise

Defined in:
eval.c

#raiseObject #raise(string) ⇒ Object #raise(exception[, string [, array]]) ⇒ Object #failObject #fail(string) ⇒ Object #fail(exception[, string [, array]]) ⇒ Object

With no arguments, raises the exception in $! or raises a RuntimeError if $! 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 begin...end blocks.

raise "Failed to create socket"
raise ArgumentError, "No parameters", caller


614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
# File 'eval.c', line 614

static VALUE
rb_f_raise(int argc, VALUE *argv)
{
    VALUE err;
    if (argc == 0) {
  err = get_errinfo();
  if (!NIL_P(err)) {
      argc = 1;
      argv = &err;
  }
    }
    rb_raise_jump(rb_make_exception(argc, argv));

    UNREACHABLE;
}