Skip to content

Commit

Permalink
Lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulDoyle-EA committed Feb 10, 2025
1 parent cb64d62 commit 3f47bbd
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions app/jobs/waste_carriers_engine/govpay_webhook_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,7 @@ def perform(webhook_body)
raise ArgumentError, "Unrecognised Govpay webhook type"
end
rescue StandardError => e
service_type = webhook_body.dig("resource", "moto") ? "back_office" : "front_office"
Rails.logger.error "Error running GovpayWebhookJob (#{service_type}): #{e}"
notification_params = {
refund_id: webhook_body&.dig("resource", "refund_id"),
payment_id: webhook_body&.dig("resource", "payment_id"),
service_type: service_type
}

if FeatureToggle.active?("enhanced_govpay_logging")
notification_params[:webhook_body] = sanitize_webhook_body(webhook_body)
end

Airbrake.notify(e, notification_params)
handle_error(e, webhook_body)
end

private
Expand All @@ -40,5 +28,21 @@ def sanitize_webhook_body(body)

sanitized
end

def handle_error(error, webhook_body)
service_type = webhook_body.dig("resource", "moto") ? "back_office" : "front_office"
Rails.logger.error "Error running GovpayWebhookJob (#{service_type}): #{error}"
notification_params = {
refund_id: webhook_body&.dig("resource", "refund_id"),
payment_id: webhook_body&.dig("resource", "payment_id"),
service_type: service_type
}

if FeatureToggle.active?("enhanced_govpay_logging")
notification_params[:webhook_body] = sanitize_webhook_body(webhook_body)
end

Airbrake.notify(error, notification_params)
end
end
end

0 comments on commit 3f47bbd

Please sign in to comment.