Skip to content

Commit

Permalink
Add exception hanlding for 'Chef::Exceptions::ValidationFailed'. This…
Browse files Browse the repository at this point in the history
… exception is thrown if data bag is not found.

Chef does do good job of handling absence of data bag (or data bag item)
  • Loading branch information
Pushkar Raste committed Jun 9, 2014
1 parent b30f30a commit e506877
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libraries/chef_nexus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ def encrypted_data_bag_item(node, data_bag, data_bag_item)
Mash.from_hash(item.to_hash)
rescue Net::HTTPServerException => e
nil

# chef_data_bag_item.rb fails to handle scenario of missing data bag :-(,
# it reports this as Chef::Exceptions::ValidationFailed exception.
# Adding a different rescue block if things exception needs to be handled differently
rescue Chef::Exceptions::ValidationFailed => e
nil
end
end
end
Expand Down

0 comments on commit e506877

Please sign in to comment.