lib/manageiq/api/client/collection.rb in manageiq-api-client-0.3.0 vs lib/manageiq/api/client/collection.rb in manageiq-api-client-0.3.1
- old
+ new
@@ -37,12 +37,15 @@
args = args.flatten
case args.size
when 0
raise "Couldn't find resource without an 'id'"
when 1
- res = limit(1).where(:id => args[0]).to_a
- raise "Couldn't find resource with 'id' #{args}" if res.blank?
- request_array ? res : res.first
+ begin
+ res = limit(1).where(:id => args[0]).to_a
+ request_array ? res : res.first
+ rescue => err
+ raise ManageIQ::API::Client::ResourceNotFound, "Couldn't find resource with 'id' #{args}"
+ end
else
raise "Multiple resource find is not supported" unless respond_to?(:query)
query(args.collect { |id| { "id" => id } })
end
end