From 14c01486d299457d8a5e4624fe93fd26d83e644b Mon Sep 17 00:00:00 2001 From: compiledwrong Date: Sun, 5 May 2024 00:10:05 -0400 Subject: [PATCH] add error catching for whatever untested terrible thing may be happening with the new design and preventing case contact creation in prod --- app/controllers/case_contacts/form_controller.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/controllers/case_contacts/form_controller.rb b/app/controllers/case_contacts/form_controller.rb index 6e1f6bec86..b8c69b2f0f 100644 --- a/app/controllers/case_contacts/form_controller.rb +++ b/app/controllers/case_contacts/form_controller.rb @@ -139,14 +139,22 @@ def case_contact_params # Deletes the current associations (from the join table) only if the submitted form body has the parameters for # the contact_type ids. def remove_unwanted_contact_types - if params.dig(:case_contact, :case_contact_contact_type_attributes) - @case_contact.case_contact_contact_type.destroy_all + begin + if params.dig(:case_contact, :case_contact_contact_type_attributes) # TODO this sometimes raises errors in prod. + @case_contact.case_contact_contact_type.destroy_all + end + rescue => e + Bugsnag.notify(e) end end def remove_nil_draft_ids - if params.dig(:case_contact, :draft_case_ids) - params[:case_contact][:draft_case_ids] -= [""] + begin + if params.dig(:case_contact, :draft_case_ids) + params[:case_contact][:draft_case_ids] -= [""] + end + rescue => e + Bugsnag.notify(e) end end