From 0edeec197ff87a01326dbd92462bc10eb0112a62 Mon Sep 17 00:00:00 2001 From: Jonathan Hooper Date: Wed, 30 Nov 2022 11:11:09 -0500 Subject: [PATCH 1/2] Add exception handling back to DDP proofer A recent refactor of the DDP proofer failed to include this rescue. As a result exceptions are unhandled and raised to the background job and cause a background job failure. --- app/services/proofing/lexis_nexis/ddp/proofer.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/services/proofing/lexis_nexis/ddp/proofer.rb b/app/services/proofing/lexis_nexis/ddp/proofer.rb index cc338d2b1f8..adfd8cc733d 100644 --- a/app/services/proofing/lexis_nexis/ddp/proofer.rb +++ b/app/services/proofing/lexis_nexis/ddp/proofer.rb @@ -64,6 +64,9 @@ def send_verification_request(applicant) def proof(applicant) response = send_verification_request(applicant) process_response(response) + rescue => exception + NewRelic::Agent.notice_error(exception) + Proofing::Result.new(exception: exception) end private From 9f66043a745896fd75263d1ce81e2bcba078fc1c Mon Sep 17 00:00:00 2001 From: Jonathan Hooper Date: Wed, 30 Nov 2022 11:24:39 -0500 Subject: [PATCH 2/2] [skip changelog] --- .../proofing/lexis_nexis/ddp/proofing_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/services/proofing/lexis_nexis/ddp/proofing_spec.rb b/spec/services/proofing/lexis_nexis/ddp/proofing_spec.rb index 5515c853643..ea33ae3592f 100644 --- a/spec/services/proofing/lexis_nexis/ddp/proofing_spec.rb +++ b/spec/services/proofing/lexis_nexis/ddp/proofing_spec.rb @@ -82,5 +82,21 @@ expect(result.errors).to be_empty end end + + context 'when the response raises an exception' do + let(:response_body) { '' } + + it 'returns an exception result' do + error = RuntimeError.new('hi') + + expect(NewRelic::Agent).to receive(:notice_error).with(error) + + stub_request(:post, verification_request.url).to_raise(error) + + expect(result.success?).to eq(false) + expect(result.errors).to be_empty + expect(result.exception).to eq(error) + end + end end end