Skip to content

Commit f2659de

Browse files
committed
[CHEF-1326] catch 404s from couch and re-raise as 404s from merb
1 parent 23410ae commit f2659de

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎chef-server-api/app/controllers/cookbooks.rb‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,14 @@ def destroy
146146
private
147147

148148
def get_cookbook_version(name, version)
149-
begin
150-
Chef::CookbookVersion.cdb_load(name, version)
151-
rescue Chef::Exceptions::CouchDBNotFound => e
149+
Chef::CookbookVersion.cdb_load(name, version)
150+
rescue Chef::Exceptions::CouchDBNotFound => e
151+
raise NotFound, "Cannot find a cookbook named #{name} with version #{version}"
152+
rescue Net::HTTPServerException => e
153+
if e.to_s =~ /^404/
152154
raise NotFound, "Cannot find a cookbook named #{name} with version #{version}"
155+
else
156+
raise
153157
end
154158
end
155159

0 commit comments

Comments
 (0)