Project

General

Profile

Actions

Bug #9358

closed

TracePoint's raise event should throw 'not supported by this event (RuntimeError)' on calling return_value

Added by andhapp (Anuj Dutta) over 10 years ago. Updated almost 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
2.1.0
Backport:
[ruby-core:59521]

Description

=begin
Hello,

In TracePoint class, if a particular introspection method is not supported then 'not supported by this event (RuntimeError)' is thrown.

=== Line event doesn't support raised_exception

 TracePoint.trace(:line) do |tp|
   p tp.raised_exception
 end

 #=> RuntimeError: 'raised_exception' not supported by this event

However, that doesn't seem to happen for 'raise' event. The call to return_value stops the trace altogether. Here's the code to reproduce it:

=== Code

class Car
def self.start
begin
raise StandardError.new, 'Error!'
rescue
end
end
end

TracePoint.trace(:raise) do |tp|
p tp.raised_exception
p [tp.return_value, tp.raised_exception]
end

Car.start

=== Expected Output
#=> #<StandardError: Error!>
#=> `return_value': not supported by this event (RuntimeError)

=== Actual Output
#=> #<StandardError: Error!>

Is this expected behaviour?

Thanks

=end

Actions

Also available in: Atom PDF

Like0
Like0