Skip to content

Commit

Permalink
Print nice error when module not found in forge
Browse files Browse the repository at this point in the history
Closes #5
  • Loading branch information
rodjek committed Jun 20, 2012
1 parent 5666e90 commit cf0ce30
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/librarian/puppet/source/forge.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ def initialize(source, name)


def versions def versions
data = api_call("#{name}.json") data = api_call("#{name}.json")
if data.nil?
raise Error, "Unable to find module '#{name}' on #{source}"
end

data['releases'].map { |r| r['version'] }.sort.reverse data['releases'].map { |r| r['version'] }.sort.reverse
end end


Expand Down Expand Up @@ -79,9 +83,12 @@ def cache_version_unpacked!(version)
def api_call(path) def api_call(path)
base_url = source.to_s base_url = source.to_s
resp = Net::HTTP.get_response(URI.parse("#{base_url}/#{path}")) resp = Net::HTTP.get_response(URI.parse("#{base_url}/#{path}"))
data = resp.body if resp.code.to_i != 200

nil
JSON.parse(data) else
data = resp.body
JSON.parse(data)
end
end end
end end


Expand Down

0 comments on commit cf0ce30

Please sign in to comment.