method

report_on_exception=

Importance_2
v2_4_6 - Show latest stable - 0 notes - Class: Thread
report_on_exception=(p1) public

When set to true, all threads will report the exception if an exception is raised. Returns the new state.

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
prog.rb:4: Exception from thread (RuntimeError)
 from prog.rb:2:in `initialize'
 from prog.rb:2:in `new'
 from prog.rb:2
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=.

Show source
Register or log in to add new notes.