summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Cowie <jonlives@gmail.com>2018-02-27 13:47:40 +0000
committerJon Cowie <jonlives@gmail.com>2018-02-27 13:47:40 +0000
commit7ef8048ff6ac8972fc7dcce6c93e45becefb32f4 (patch)
treead22d6905f7a7bd015f2d69af7986285ca368520
parentac9d4e7de1b10293da89f2d1322127ea39a92bd0 (diff)
downloadchef-7ef8048ff6ac8972fc7dcce6c93e45becefb32f4.tar.gz
Don't swallow file exceptions but rather re-raise with clearer text
Signed-off-by: Jon Cowie <jonlives@gmail.com>
-rw-r--r--lib/chef/data_collector.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/chef/data_collector.rb b/lib/chef/data_collector.rb
index dee25958c4..3eb6565fa8 100644
--- a/lib/chef/data_collector.rb
+++ b/lib/chef/data_collector.rb
@@ -519,10 +519,14 @@ class Chef
def validate_and_create_file(file)
send_to_file_location(file, "")
return true
+ # Rescue exceptions raised by the file path being non-existent or not writeable and re-raise them to the user
+ # with clearer explanatory text.
rescue Errno::ENOENT
- return false
+ raise Chef::Exceptions::ConfigurationError,
+ "Chef::Config[:data_collector][:output_locations][:files] contains the location #{file}, which is a non existent file path."
rescue Errno::EACCES
- return false
+ raise Chef::Exceptions::ConfigurationError,
+ "Chef::Config[:data_collector][:output_locations][:files] contains the location #{file}, which cannnot be written to by Chef."
end
def validate_data_collector_server_url!