summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVivek Singh <vivek.singh@msystechnologies.com>2020-07-31 17:16:37 +0530
committerVivek Singh <vivek.singh@msystechnologies.com>2020-07-31 17:16:37 +0530
commit94b8f2f535632592363bc4f64b5792265344f593 (patch)
tree0b3348b69aec186e8776fba264766ee3b9bbe976
parenta0675c3219636a442c3d303cebfcd9e28ea2ebd9 (diff)
downloadchef-94b8f2f535632592363bc4f64b5792265344f593.tar.gz
Per resource error detail client run
- Add error_description to action_collection of resource based object. - Add error hash message class, message and detail to resource object. Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
-rw-r--r--lib/chef/action_collection.rb4
-rw-r--r--lib/chef/data_collector/run_end_message.rb10
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/chef/action_collection.rb b/lib/chef/action_collection.rb
index efe03fff5f..1ac47630a9 100644
--- a/lib/chef/action_collection.rb
+++ b/lib/chef/action_collection.rb
@@ -44,6 +44,9 @@ class Chef
# @return [Exception] The exception that was thrown
attr_accessor :exception
+ # @return [Hash] JSON-formatted error description from the Chef::Formatters::ErrorMapper
+ attr_accessor :error_description
+
# @return [Numeric] The elapsed time in seconds with machine precision
attr_accessor :elapsed_time
@@ -223,6 +226,7 @@ class Chef
current_record.status = :failed
current_record.exception = exception
+ current_record.error_description = Formatters::ErrorMapper.resource_failed(new_resource, action, exception).for_json
end
# Hook called after an action is completed. This is always called, even if the action fails.
diff --git a/lib/chef/data_collector/run_end_message.rb b/lib/chef/data_collector/run_end_message.rb
index 4bb4fe2852..c43c21e5ff 100644
--- a/lib/chef/data_collector/run_end_message.rb
+++ b/lib/chef/data_collector/run_end_message.rb
@@ -133,7 +133,15 @@ class Chef
end
hash["conditional"] = action_record.conditional.to_text if action_record.status == :skipped
- hash["error_message"] = action_record.exception.message unless action_record.exception.nil?
+
+ unless action_record.exception.nil?
+ hash["error"] = {
+ "class" => action_record.exception.class,
+ "message" => action_record.exception.message,
+ "backtrace" => action_record.exception.backtrace,
+ "description" => action_record.error_description,
+ }
+ end
hash
end