Skip to content
This repository
Browse code

add Pry.last_internal_error

This is set to the last CommandError, SlopError, etc. Most often
raised by commands. This info is useful to pry devs debugging
otherwise opaque command errors.
  • Loading branch information...
commit 0cb9a497050169c6de67da33291c606e5289685a 1 parent 6c083f1
John Mair authored January 20, 2013
4  lib/pry/pry_class.rb
@@ -55,6 +55,10 @@ def self.delegate_accessors(delagatee, *names)
55 55
     # @return [Binding] A top level binding with no local variables
56 56
     attr_accessor :toplevel_binding
57 57
 
  58
+    # @return [Exception, nil] The last pry internal error.
  59
+    #   (a CommandError in most cases)
  60
+    attr_accessor :last_internal_error
  61
+
58 62
     # plugin forwardables
59 63
     def_delegators :@plugin_manager, :plugins, :load_plugins, :locate_plugins
60 64
 
1  lib/pry/pry_instance.rb
@@ -446,6 +446,7 @@ def process_command(val)
446 446
   def process_command_safely(val)
447 447
     process_command(val)
448 448
   rescue CommandError, Slop::InvalidOptionError, MethodSource::SourceNotFoundError => e
  449
+    Pry.last_internal_error = e
449 450
     output.puts "Error: #{e.message}"
450 451
     true
451 452
   end

0 notes on commit 0cb9a49

Please sign in to comment.
Something went wrong with that request. Please try again.