Skip to content
This repository
Browse code

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.
  • Loading branch information...
commit 6e3800fa7424682123ab430169813f687a4f5586 1 parent 90f9568
John Mair authored January 29, 2013

Showing 1 changed file with 2 additions and 2 deletions. Show diff stats Hide diff stats

  1. 4  lib/pry/module_candidate.rb
4  lib/pry/module_candidate.rb
@@ -52,8 +52,8 @@ def initialize(wrapper, rank)
52 52
       # @return [String] The source for the candidate, i.e the
53 53
       #   complete module/class definition.
54 54
       def source
  55
+        return nil if file.nil?
55 56
         return @source if @source
56  
-        raise CommandError, "Could not locate source for #{wrapped}!" if file.nil?
57 57
 
58 58
         @source = strip_leading_whitespace(Pry::Code.from_file(file).expression_at(line, number_of_lines_in_first_chunk))
59 59
       end
@@ -61,8 +61,8 @@ def source
61 61
       # @raise [Pry::CommandError] If documentation cannot be found.
62 62
       # @return [String] The documentation for the candidate.
63 63
       def doc
  64
+        return nil if file.nil?
64 65
         return @doc if @doc
65  
-        raise CommandError, "Could not locate doc for #{wrapped}!" if file.nil?
66 66
 
67 67
         @doc = strip_leading_hash_and_whitespace_from_ruby_comments(Pry::Code.from_file(file).comment_describing(line))
68 68
       end

0 notes on commit 6e3800f

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