Browse Source

Update error handling

pull/2989/head
Manny Dinssa 2 months ago
parent
commit
fe7e3ad987
  1. 6
      app/services/uprn_client.rb

6
app/services/uprn_client.rb

@ -20,11 +20,11 @@ class UprnClient
end
def result
@result ||= begin
@result ||= if response.code == 200
parsed_response = JSON.parse(response.body)
parsed_response.dig("results", 0, "DPA") || parsed_response.dig("results", 0, "LPI")
rescue JSON::ParserError => e
Rails.logger.error("Failed to parse JSON response: #{e.message}")
else
Rails.logger.error("Unexpected response code: #{response.code}")
nil
end
end

Loading…
Cancel
Save