From a42eec885301faecdc2e79f2eaa85c3fc0289c2c Mon Sep 17 00:00:00 2001 From: John Mair Date: Thu, 3 Jan 2013 16:49:07 +0100 Subject: [PATCH] minor refactor to wtf command --- lib/pry/commands/wtf.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/pry/commands/wtf.rb b/lib/pry/commands/wtf.rb index c5f1ef95..c32bd332 100644 --- a/lib/pry/commands/wtf.rb +++ b/lib/pry/commands/wtf.rb @@ -26,9 +26,9 @@ class Pry end def process - raise Pry::CommandError, "No most-recent exception" unless _pry_.last_exception + raise Pry::CommandError, "No most-recent exception" unless exception - output.puts "#{text.bold('Exception:')} #{_pry_.last_exception.class}: #{_pry_.last_exception}\n--" + output.puts "#{text.bold('Exception:')} #{exception.class}: #{exception}\n--" if opts.verbose? output.puts with_line_numbers(backtrace) else @@ -38,12 +38,16 @@ class Pry private + def exception + _pry_.last_exception + end + def with_line_numbers(bt) Pry::Code.new(bt, 0, :text).with_line_numbers.to_s end def backtrace - _pry_.last_exception.backtrace + exception.backtrace end def size_of_backtrace