From 509b0176ccf7c75ce2a908e2c4cb690fe962a26e Mon Sep 17 00:00:00 2001 From: Jennica Stiehl <25069483+stiehlrod@users.noreply.github.com> Date: Tue, 28 Mar 2023 12:01:50 -0600 Subject: [PATCH] Changes rescue (#12273) --- .../v1/forms/intent_to_file_controller.rb | 16 +++++++++------- modules/claims_api/lib/bgs_service/local_bgs.rb | 6 ------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/modules/claims_api/app/controllers/claims_api/v1/forms/intent_to_file_controller.rb b/modules/claims_api/app/controllers/claims_api/v1/forms/intent_to_file_controller.rb index f80d233547b..51bb21e35a4 100644 --- a/modules/claims_api/app/controllers/claims_api/v1/forms/intent_to_file_controller.rb +++ b/modules/claims_api/app/controllers/claims_api/v1/forms/intent_to_file_controller.rb @@ -30,13 +30,15 @@ def submit_form_0966 ClaimsApi::Logger.log('itf', detail: '0966 - Controller Actions Completed') bgs_response = local_bgs_service.insert_intent_to_file(intent_to_file_options) - ClaimsApi::IntentToFile.create!(status: ClaimsApi::IntentToFile::SUBMITTED, cid: token.payload['cid']) - ClaimsApi::Logger.log('itf', detail: 'Submitted to BGS') - render json: bgs_response, - serializer: ClaimsApi::IntentToFileSerializer - rescue Faraday::ServerError => e - ClaimsApi::IntentToFile.create!(status: ClaimsApi::IntentToFile::ERRORED, cid: token.payload['cid']) - raise ::Common::Exceptions::UnprocessableEntity.new(detail: e.message&.split('>')&.last) + if bgs_response.empty? + ClaimsApi::IntentToFile.create!(status: ClaimsApi::IntentToFile::ERRORED, cid: token.payload['cid']) + raise ::Common::Exceptions::UnprocessableEntity.new(detail: 'Veteran ID not found') + else + ClaimsApi::IntentToFile.create!(status: ClaimsApi::IntentToFile::SUBMITTED, cid: token.payload['cid']) + ClaimsApi::Logger.log('itf', detail: 'Submitted to BGS') + render json: bgs_response, + serializer: ClaimsApi::IntentToFileSerializer + end end # GET current intent to file status based on type. diff --git a/modules/claims_api/lib/bgs_service/local_bgs.rb b/modules/claims_api/lib/bgs_service/local_bgs.rb index 92993a2eb2e..bfc40c26b53 100644 --- a/modules/claims_api/lib/bgs_service/local_bgs.rb +++ b/modules/claims_api/lib/bgs_service/local_bgs.rb @@ -104,12 +104,6 @@ def make_request(endpoint:, action:, body:, key: nil) # rubocop:disable Metrics/ }) end - if response.status >= 500 - status_and_reason = "HTTP status: #{response.status}, reason: #{response.reason_phrase}" - ClaimsApi::Logger.log(action, detail: status_and_reason) - raise Faraday::ServerError, response.reason_phrase - end - log_duration event: 'parsed_response', key: key do parsed_response(response, action, key) end