Permalink
Browse files

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...
1 parent 6c083f1 commit 0cb9a497050169c6de67da33291c606e5289685a @banister banister committed Jan 20, 2013
Showing with 5 additions and 0 deletions.
  1. +4 −0 lib/pry/pry_class.rb
  2. +1 −0 lib/pry/pry_instance.rb
View
@@ -55,6 +55,10 @@ def self.delegate_accessors(delagatee, *names)
# @return [Binding] A top level binding with no local variables
attr_accessor :toplevel_binding
+ # @return [Exception, nil] The last pry internal error.
+ # (a CommandError in most cases)
+ attr_accessor :last_internal_error
+
# plugin forwardables
def_delegators :@plugin_manager, :plugins, :load_plugins, :locate_plugins
View
@@ -446,6 +446,7 @@ def process_command(val)
def process_command_safely(val)
process_command(val)
rescue CommandError, Slop::InvalidOptionError, MethodSource::SourceNotFoundError => e
+ Pry.last_internal_error = e
output.puts "Error: #{e.message}"
true
end

0 comments on commit 0cb9a49

Please sign in to comment.