Skip to content

Commit a2b3ee2

Browse files
bitwise-aidenko1
authored andcommitted
Update info c <exp> based on PR comment
This will now supress any errors during evaluation, still preventing the debugger from crashing. Instead it will now output the `not a Module` message only when the constant is defined.
1 parent 5b14e0a commit a2b3ee2

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

lib/debug/thread_client.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -608,12 +608,17 @@ def iter_consts c, names = {}
608608

609609
def get_consts expr = nil, only_self: false, &block
610610
if expr && !expr.empty?
611-
_self = frame_eval(expr)
612-
if M_KIND_OF_P.bind_call(_self, Module)
613-
iter_consts _self, &block
614-
return
611+
begin
612+
_self = frame_eval(expr, re_raise: true)
613+
rescue Exception => e
614+
# ignore
615615
else
616-
puts "#{_self.inspect} (by #{expr}) is not a Module."
616+
if M_KIND_OF_P.bind_call(_self, Module)
617+
iter_consts _self, &block
618+
return
619+
else
620+
puts "#{_self.inspect} (by #{expr}) is not a Module."
621+
end
617622
end
618623
elsif _self = current_frame&.self
619624
cs = {}

test/console/info_test.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,6 @@ def test_info_constant_with_expression_errors
258258
type "info constants foo"
259259
assert_line_text([
260260
/eval error: undefined local variable or method `foo' for main/,
261-
/.*/,
262-
/nil \(by foo\) is not a Module./
263261
])
264262

265263
type "c"

0 commit comments

Comments
 (0)