class method
Thread.report_on_exception=
(untyped report_on_exception) -> untyped
Thread.report_on_exception= boolean → true or false
thread.c
View on GitHub ↗
static VALUE
rb_thread_s_report_exc_set(VALUE self, VALUE val)
{
GET_THREAD()->vm->thread_report_on_exception = RTEST(val);
return val;
}
Returns the new state. When set to true, all threads created afterwards will inherit the condition and report a message on $stderr if an exception kills a thread:
Example
Thread.report_on_exception = true t1 = Thread.new do puts "In new thread" raise "Exception from thread" end sleep(1) puts "In the main thread"
This will produce:
In new thread #<Thread:...prog.rb:2> terminated with exception (report_on_exception is true): Traceback (most recent call last): prog.rb:4:in `block in <main>': Exception from thread (RuntimeError) In the main thread
See also ::report_on_exception.
There is also an instance level method to set this for a specific thread, see report_on_exception=.
See also
.report_on_exception
#report_on_exception
#report_on_exception=
.start
also in
4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0