Skip to content

Commit

Permalink
Pry::WrappedModule#source no longer raises if it can't find source.
Browse files Browse the repository at this point in the history
This is not an exceptional situation so an exception should not be used. nil is now returned instead.
  • Loading branch information
banister committed Jan 29, 2013
1 parent 90f9568 commit 6e3800f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/pry/module_candidate.rb
Expand Up @@ -52,17 +52,17 @@ 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

# @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
Expand Down

0 comments on commit 6e3800f

Please sign in to comment.