Skip to content

Commit

Permalink
Fix Ruby warning about uninitialized instance variable
Browse files Browse the repository at this point in the history
Instead of trying to get the instance variable and throwing it away to
see if it's there, just check to see if it's there. This fixes the Ruby
warning:

> warning: instance variable @rescue_bindings not initialized
  • Loading branch information
amarshall committed Jul 28, 2013
1 parent 9e8544b commit c79c662
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/pry-rescue/core_ext.rb
Expand Up @@ -33,7 +33,7 @@ def rescue(&block)
# end
#
def rescued(e=$!)
if e.instance_variable_get(:@rescue_bindings)
if e.instance_variable_defined?(:@rescue_bindings)
PryRescue.enter_exception_context(e)
else
stack = ''
Expand Down Expand Up @@ -73,7 +73,7 @@ def rescued(e=$!)
def enable_rescuing!(block=nil)
Interception.listen(block) do |exception, binding|
bindings = binding.respond_to?(:callers) ? binding.callers : [binding]
unless exception.instance_variable_get(:@rescue_bindings)
unless exception.instance_variable_defined?(:@rescue_bindings)
exception.instance_variable_set(:@rescue_bindings, bindings)
exception.instance_variable_set(:@rescue_cause, $!)
end
Expand Down

0 comments on commit c79c662

Please sign in to comment.