End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
Thread.abort_on_exception=
Thread.abort_on_exception= boolean → true or false
thread.c
View on GitHub ↗
static VALUE
rb_thread_s_abort_exc_set(VALUE self, VALUE val)
{
GET_THREAD()->vm->thread_abort_on_exception = RTEST(val);
return val;
}
When set to true, if any thread is aborted by an exception, the raised exception will be re-raised in the main thread. Returns the new state.
Example
Thread.abort_on_exception = true t1 = Thread.new do puts "In new thread" raise "Exception from thread" end sleep(1) puts "not reached"
This will produce:
In new thread prog.rb:4: Exception from thread (RuntimeError) from prog.rb:2:in `initialize' from prog.rb:2:in `new' from prog.rb:2
See also ::abort_on_exception.
There is also an instance level method to set this for a specific thread, see abort_on_exception=.
See also
.abort_on_exception
#abort_on_exception
#abort_on_exception=
.current
also in
4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0