Forum: Ruby-core [ruby-trunk - Bug #7622][Open] Can't grab exceptions at (|c_|b_)return event hooks

Posted by ko1 (Koichi Sasada) (Guest)
on 2012-12-25 10:01
(Received via mailing list)
Issue #7622 has been reported by ko1 (Koichi Sasada).

----------------------------------------
Bug #7622: Can't grab exceptions at (|c_|b_)return event hooks
https://bugs.ruby-lang.org/issues/7622

Author: ko1 (Koichi Sasada)
Status: Open
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: core
Target version: 2.0.0
ruby -v: ruby 2.0.0dev (2012-12-21 trunk 38515) [i386-mswin32_100]


The following code raise uncaught error:

test.rb:14:in `block in <main>': FooError (FooError)
  from test.rb:3:in `m1'
  from test.rb:7:in `m2'
  from test.rb:19:in `block in <main>'
  from test.rb:17:in `times'
  from test.rb:17:in `<main>'

But should be caught at line "rescue FooError => e".

# code:
def m1
  raise
end

def m2
  m1
end

class FooError < Exception; end

TracePoint.trace{|tp|
  p tp
  raise FooError if tp.event == :return && tp.method_id == :m1
}

1.times{
  begin
    m2
  rescue FooError => e
    p e
  end
}
Posted by ko1 (Koichi Sasada) (Guest)
on 2012-12-25 10:15
(Received via mailing list)
Issue #7622 has been updated by ko1 (Koichi Sasada).


`ensure' is also ignored.

----------------------------------------
Bug #7622: Can't grab exceptions at (|c_|b_)return event hooks
https://bugs.ruby-lang.org/issues/7622#change-35058

Author: ko1 (Koichi Sasada)
Status: Open
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: core
Target version: 2.0.0
ruby -v: ruby 2.0.0dev (2012-12-21 trunk 38515) [i386-mswin32_100]


The following code raise uncaught error:

test.rb:14:in `block in <main>': FooError (FooError)
  from test.rb:3:in `m1'
  from test.rb:7:in `m2'
  from test.rb:19:in `block in <main>'
  from test.rb:17:in `times'
  from test.rb:17:in `<main>'

But should be caught at line "rescue FooError => e".

# code:
def m1
  raise
end

def m2
  m1
end

class FooError < Exception; end

TracePoint.trace{|tp|
  p tp
  raise FooError if tp.event == :return && tp.method_id == :m1
}

1.times{
  begin
    m2
  rescue FooError => e
    p e
  end
}
Posted by ko1 (Koichi Sasada) (Guest)
on 2012-12-25 14:34
(Received via mailing list)
Issue #7622 has been updated by ko1 (Koichi Sasada).

Status changed from Open to Closed

r38601 may solve this issue.
----------------------------------------
Bug #7622: Can't grab exceptions at (|c_|b_)return event hooks
https://bugs.ruby-lang.org/issues/7622#change-35067

Author: ko1 (Koichi Sasada)
Status: Closed
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: core
Target version: 2.0.0
ruby -v: ruby 2.0.0dev (2012-12-21 trunk 38515) [i386-mswin32_100]


The following code raise uncaught error:

test.rb:14:in `block in <main>': FooError (FooError)
  from test.rb:3:in `m1'
  from test.rb:7:in `m2'
  from test.rb:19:in `block in <main>'
  from test.rb:17:in `times'
  from test.rb:17:in `<main>'

But should be caught at line "rescue FooError => e".

# code:
def m1
  raise
end

def m2
  m1
end

class FooError < Exception; end

TracePoint.trace{|tp|
  p tp
  raise FooError if tp.event == :return && tp.method_id == :m1
}

1.times{
  begin
    m2
  rescue FooError => e
    p e
  end
}
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.