From 6e3800fa7424682123ab430169813f687a4f5586 Mon Sep 17 00:00:00 2001 From: John Mair Date: Tue, 29 Jan 2013 01:05:50 +0100 Subject: [PATCH] Pry::WrappedModule#source no longer raises if it can't find source. This is not an exceptional situation so an exception should not be used. nil is now returned instead. --- lib/pry/module_candidate.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pry/module_candidate.rb b/lib/pry/module_candidate.rb index 0d5dabd64..9e9f7e69a 100644 --- a/lib/pry/module_candidate.rb +++ b/lib/pry/module_candidate.rb @@ -52,8 +52,8 @@ def initialize(wrapper, rank) # @return [String] The source for the candidate, i.e the # complete module/class definition. def source + return nil if file.nil? return @source if @source - raise CommandError, "Could not locate source for #{wrapped}!" if file.nil? @source = strip_leading_whitespace(Pry::Code.from_file(file).expression_at(line, number_of_lines_in_first_chunk)) end @@ -61,8 +61,8 @@ def source # @raise [Pry::CommandError] If documentation cannot be found. # @return [String] The documentation for the candidate. def doc + return nil if file.nil? return @doc if @doc - raise CommandError, "Could not locate doc for #{wrapped}!" if file.nil? @doc = strip_leading_hash_and_whitespace_from_ruby_comments(Pry::Code.from_file(file).comment_describing(line)) end