Skip to content
Snippets Groups Projects
Commit 77e83557 authored by Robert Wachs's avatar Robert Wachs
Browse files

Google, Okf lookup: fix exception in case response is no valid json

Google and Okf perform additional checks to determine if a request is
valid. It needs to be checked first if json parsing succeeded before
accessing values of it, or else an error will occur.
parent 40ac60c4
No related merge requests found
......@@ -19,7 +19,8 @@ module Geocoder::Lookup
private # ---------------------------------------------------------------
def valid_response?(response)
status = parse_json(response.body)["status"]
json = parse_json(response.body)
status = json["status"] if json
super(response) and ['OK', 'ZERO_RESULTS'].include?(status)
end
......
......@@ -15,7 +15,8 @@ module Geocoder::Lookup
private # ---------------------------------------------------------------
def valid_response?(response)
status = parse_json(response.body)["status"]
json = parse_json(response.body)
status = json["status"] if json
super(response) and ['OK', 'ZERO_RESULTS'].include?(status)
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment