summaryrefslogtreecommitdiff
path: root/lib/irb/inspector.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/irb/inspector.rb')
-rw-r--r--lib/irb/inspector.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/irb/inspector.rb b/lib/irb/inspector.rb
index 50f6ebf383..bdfa282f0d 100644
--- a/lib/irb/inspector.rb
+++ b/lib/irb/inspector.rb
@@ -35,6 +35,7 @@ module IRB # :nodoc:
# irb(main):001:0> "what?" #=> omg! what?
#
class Inspector
+ KERNEL_INSPECT = Object.instance_method(:inspect)
# Default inspectors available to irb, this includes:
#
# +:pp+:: Using Kernel#pretty_inspect
@@ -93,9 +94,18 @@ module IRB # :nodoc:
# Proc to call when the input is evaluated and output in irb.
def inspect_value(v)
@inspect.call(v)
- rescue
- puts "(Object doesn't support #inspect)"
- ''
+ rescue => e
+ puts "An error occurred when inspecting the object: #{e.inspect}"
+
+ begin
+ # TODO: change this to bind_call when we drop support for Ruby 2.6
+ puts "Result of Kernel#inspect: #{KERNEL_INSPECT.bind(v).call}"
+ ''
+ rescue => e
+ puts "An error occurred when running Kernel#inspect: #{e.inspect}"
+ puts e.backtrace.join("\n")
+ ''
+ end
end
end