Browse Source

Improve import error logging (#1382)

CLDC-1820-allow-deactivation-or-reactivation-of-last-year-schemes-and-locations-in-crossover-period
kosiakkatrina 2 years ago committed by GitHub
parent
commit
dc3c118bbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      app/services/imports/sales_logs_import_service.rb

10
app/services/imports/sales_logs_import_service.rb

@ -168,8 +168,16 @@ module Imports
end end
end end
def rescue_validation_or_raise(sales_log, _attributes, _previous_status, exception) def rescue_validation_or_raise(sales_log, attributes, _previous_status, exception)
@logger.error("Log #{sales_log.old_id}: Failed to import") @logger.error("Log #{sales_log.old_id}: Failed to import")
sales_log.errors.each do |error|
@logger.error("Validation error: Field #{error.attribute}:")
@logger.error("\tOwning Organisation: #{sales_log.owning_organisation&.name}")
@logger.error("\tOld CORE ID: #{sales_log.old_id}")
@logger.error("\tOld CORE: #{attributes[error.attribute.to_s]&.inspect}")
@logger.error("\tNew CORE: #{sales_log.read_attribute(error.attribute)&.inspect}")
@logger.error("\tError message: #{error.type}")
end
raise exception raise exception
end end

Loading…
Cancel
Save