Skip to content

Commit

Permalink
Don't explode if the file we're in doesn't exist.
Browse files Browse the repository at this point in the history
This happens particularly in testing where you want to delete files
after each test, but the REPL state isn't reset correctly.
  • Loading branch information
ConradIrwin committed Sep 10, 2011
1 parent 9c8eb61 commit 76d1c4f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/pry/default_commands/context.rb
Expand Up @@ -147,6 +147,10 @@ module DefaultCommands
set_file_and_dir_locals(file)
output.puts "\n#{text.bold('From:')} #{file} @ line #{line_num} in #{klass}##{meth_name}:\n\n"

unless File.readable?(file)
output.puts "Cannot open #{file.inspect} for reading."
next
end

# This method inspired by http://rubygems.org/gems/ir_b
File.open(file).each_with_index do |line, index|
Expand Down

0 comments on commit 76d1c4f

Please sign in to comment.