lib/multiwoven/integrations/destination/salesforce_crm/client.rb in multiwoven-integrations-0.1.64 vs lib/multiwoven/integrations/destination/salesforce_crm/client.rb in multiwoven-integrations-0.1.72

- old
+ new

@@ -23,19 +23,28 @@ def discover(_connection_config = nil) catalog = build_catalog(load_catalog) catalog.to_multiwoven_message rescue StandardError => e - handle_exception("SALESFORCE:CRM:DISCOVER:EXCEPTION", "error", e) + handle_exception(e, { + context: "SALESFORCE:CRM:DISCOVER:EXCEPTION", + type: "error" + }) end def write(sync_config, records, action = "create") @action = sync_config.stream.action || action + @sync_config = sync_config initialize_client(sync_config.destination.connection_specification) process_records(records, sync_config.stream) rescue StandardError => e - handle_exception("SALESFORCE:CRM:WRITE:EXCEPTION", "error", e) + handle_exception(e, { + context: "SALESFORCE:CRM:WRITE:EXCEPTION", + type: "error", + sync_id: @sync_config.sync_id, + sync_run_id: @sync_config.sync_run_id + }) end private def initialize_client(config) @@ -56,10 +65,16 @@ records.each do |record_object| record = extract_data(record_object, properties) process_record(stream, record) write_success += 1 rescue StandardError => e - handle_exception("SALESFORCE:CRM:WRITE:EXCEPTION", "error", e) + # TODO: add sync_id and sync_run_id to the logs + handle_exception(e, { + context: "SALESFORCE:CRM:WRITE:EXCEPTION", + type: "error", + sync_id: @sync_config.sync_id, + sync_run_id: @sync_config.sync_run_id + }) write_failure += 1 end tracking_message(write_success, write_failure) end