Skip to content

Commit

Permalink
Changes rescue (#12273)
Browse files Browse the repository at this point in the history
  • Loading branch information
stiehlrod authored Mar 28, 2023
1 parent 3eeab4b commit 509b017
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 0 additions & 6 deletions modules/claims_api/lib/bgs_service/local_bgs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 509b017

Please sign in to comment.