raise(...)
public
Raises an exception (see Kernel::raise) from thr. The caller does
not have to be thr.
Thread.abort_on_exception = true
a = Thread.new { sleep(200) }
a.raise("Gotcha")
produces:
prog.rb:3: Gotcha (RuntimeError)
from prog.rb:2:in `initialize'
from prog.rb:2:in `new'
from prog.rb:2
Show source
/*
* call-seq:
* thr.raise(exception)
*
* Raises an exception (see <code>Kernel::raise</code>) from <i>thr</i>. The
* caller does not have to be <i>thr</i>.
*
* Thread.abort_on_exception = true
* a = Thread.new { sleep(200) }
* a.raise("Gotcha")
*
* <em>produces:</em>
*
* prog.rb:3: Gotcha (RuntimeError)
* from prog.rb:2:in `initialize'
* from prog.rb:2:in `new'
* from prog.rb:2
*/
static VALUE
rb_thread_raise_m(argc, argv, thread)
int argc;
VALUE *argv;
VALUE thread;
{
rb_thread_t th = rb_thread_check(thread);
if (ruby_safe_level > th->safe) {
rb_secure(4);
}
rb_thread_raise(argc, argv, th);
return Qnil; /* not reached */
}