public Method

Kernel.fail(...)

raise
raise(string)
raise(exception [, string [, array]])
fail
fail(string)
fail(exception [, string [, array]])

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

Source Code

/*
*  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
*/

static VALUE
rb_f_raise(argc, argv)
   int argc;
   VALUE *argv;
{
   rb_raise_jump(rb_make_exception(argc, argv));
   return Qnil;                /* not reached */
}
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.