method
report_on_exception=
v2_5_5 -
Show latest stable
-
0 notes -
Class: Thread
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180
- 1_9_3_125
- 1_9_3_392
- 2_1_10
- 2_2_9
- 2_4_6 (0)
- 2_5_5 (38)
- 2_6_3 (0)
- What's this?
report_on_exception=(p1)
public
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:
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=.