Project

General

Profile

Actions

Bug #2048

closed

Thread#raise: Handling of Current Exception

Added by runpaint (Run Paint Run Run) about 15 years ago. Updated over 13 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.2dev (2009-09-03 trunk 24741) [i686-linux]
Backport:
[ruby-core:25367]

Description

=begin
$ cat /tmp/thread.rb
t = Thread.new do
begin
1/0
rescue ZeroDivisionError
sleep 3
end
end

Thread.pass while t.status and t.status != "sleep"
t.raise
t.value
t.kill

$ ruby -v /tmp/thread.rb
ruby 1.9.2dev (2009-09-03 trunk 24741) [i686-linux]
/tmp/thread.rb:5:in sleep': unhandled exception from /tmp/thread.rb:5:in rescue in block in '
from /tmp/thread.rb:2:in `block in '

$ ruby8 -v /tmp/thread.rb
ruby 1.8.8dev (2009-09-04) [i686-linux]
/tmp/thread.rb:3:in /': divided by 0 (ZeroDivisionError) from /tmp/thread.rb:11:in value'
from /tmp/thread.rb:11

On 1.8 Thread#raise re-raises the current exception; on 1.9 it doesn't.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0