From 4b17ab94df0c22435f2d0c9642dac78d8340feed Mon Sep 17 00:00:00 2001 From: James Rose Date: Tue, 28 Feb 2023 11:13:21 +0000 Subject: [PATCH] Add better validation error logging to lettings import service (#1355) --- app/services/imports/lettings_logs_import_service.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/services/imports/lettings_logs_import_service.rb b/app/services/imports/lettings_logs_import_service.rb index a215e8f5a..a474f0c45 100644 --- a/app/services/imports/lettings_logs_import_service.rb +++ b/app/services/imports/lettings_logs_import_service.rb @@ -289,6 +289,15 @@ module Imports save_lettings_log(attributes, previous_status) else @logger.error("Log #{lettings_log.old_id}: Failed to import") + lettings_log.errors.each do |error| + @logger.error("Validation error: Field #{error.attribute}:") + @logger.error("\tOwning Organisation: #{lettings_log.owning_organisation&.name}") + @logger.error("\tManaging Organisation: #{lettings_log.managing_organisation&.name}") + @logger.error("\tOld CORE ID: #{lettings_log.old_id}") + @logger.error("\tOld CORE: #{attributes[error.attribute.to_s]&.inspect}") + @logger.error("\tNew CORE: #{lettings_log.read_attribute(error.attribute)&.inspect}") + @logger.error("\tError message: #{error.type}") + end raise exception end end