From 1fac900f60721f65d5c7ad6cdee597b253ae8b3b Mon Sep 17 00:00:00 2001 From: Kristina Spurgin Date: Sun, 11 Feb 2024 11:24:57 -0500 Subject: [PATCH] Return data prep errors early --- .../mapper/date_details/data_prepper.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/collectionspace/mapper/date_details/data_prepper.rb b/lib/collectionspace/mapper/date_details/data_prepper.rb index df30d6a8..0b7bc160 100644 --- a/lib/collectionspace/mapper/date_details/data_prepper.rb +++ b/lib/collectionspace/mapper/date_details/data_prepper.rb @@ -34,6 +34,10 @@ def prep if handler.grouped_handler extract_grouped_data grouped_prepped = handler.grouped_handler.prep(grouped_data) + unless grouped_prepped.errors.empty? + grouped_prepped.errors.each { |err| response.add_error(err) } + return response + end end split_data transform_data @@ -42,6 +46,8 @@ def prep clean_transformed readd_id combine_data_fields + return response unless response.errors.empty? + merge_authority_data(auth_prepped) if authority_data merge_grouped_data(grouped_prepped) if grouped_data response @@ -209,9 +215,10 @@ def merge_authority_data(auth_prepped) def merge_grouped_data(grouped_prepped) path = handler.target_path - response.combined_data[path].merge!( - grouped_prepped.combined_data[path] - ) + response.combined_data[path].tap { |data| binding.pry unless data } + .merge!( + grouped_prepped.combined_data[path] + ) grouped_prepped.errors.each { |err| response.add_error(err) } grouped_prepped.terms.each { |term| response.add_term(term) } grouped_prepped.warnings.each do |warning|