Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Print nice error when module not found in forge

Closes #5
  • Loading branch information...
commit cf0ce30104c47eeae36bdaf41f8caa4108f908b9 1 parent 5666e90
@rodjek authored
Showing with 10 additions and 3 deletions.
  1. +10 −3 lib/librarian/puppet/source/forge.rb
View
13 lib/librarian/puppet/source/forge.rb
@@ -21,6 +21,10 @@ def initialize(source, name)
def versions
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
end
@@ -79,9 +83,12 @@ def cache_version_unpacked!(version)
def api_call(path)
base_url = source.to_s
resp = Net::HTTP.get_response(URI.parse("#{base_url}/#{path}"))
- data = resp.body
-
- JSON.parse(data)
+ if resp.code.to_i != 200
+ nil
+ else
+ data = resp.body
+ JSON.parse(data)
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.