Open atheiman opened 6 years ago
Well there is an error log message, but I still would rather the error was in the exception rather than a separate log above it. For some chefspec tests the log was hidden from me b/c of my log_level configured to :fatal
, dropping the log_level to :error
shows the message as expected.
Could the 404 exception be inherited into a DataBagException
or DataBagItemException
? That should be backwards compatible to work with existing recipes like:
begin
# get the item
item = data_bag_item('bag', 'item')
rescue Net::HTTPServerException
# item doesnt exist, create the item
item = Chef::DataBagItem.new
item.data_bag('bag')
item.raw_data('id' => 'item', 'a' => 'A', 'b' => 'B')
item.save
end
can the
data_bag()
anddata_bag_item()
DSL methods provide more helpful error messages thanIdeally the error message could at least list the URL which would have the data bag name and the item name printed in the URL (
/organizations/NAME/data/NAME/ITEM
).Even better would be an error message that showed the bag name and item name more clearly than the URL (
Data bag not found: '#{bag_name}'
orData bag item not found '#{item_name}' in data bag '#{bag_name}'
)