Skip to content

Commit eb5260f

Browse files
committed
Rescue a specific error
Rescuing StandardError is prone to bugs caused by a typo or obsoleted methods.
1 parent e75a35e commit eb5260f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/irb/cmd/ls.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def execute(*arg, grep: nil)
2424
end
2525

2626
def dump_methods(o, klass, obj)
27-
singleton_class = obj.singleton_class rescue nil
27+
singleton_class = begin obj.singleton_class; rescue TypeError; nil end
2828
maps = class_method_map((singleton_class || klass).ancestors)
2929
maps.each do |mod, methods|
3030
name = mod == singleton_class ? "#{klass}.methods" : "#{mod}#methods"

0 commit comments

Comments
 (0)