Skip to content
Snippets Groups Projects
Commit ef62bde0 authored by Alex Reisner's avatar Alex Reisner
Browse files

Improve Yahoo error handling.

Add test and display Yahoo's error message in warning.
parent 96802dbc
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,7 @@ module Geocoder::Lookup
return []
end
else
warn "Yahoo Geocoding API error: #{doc['responsecode']}."
warn "Yahoo Geocoding API error: #{doc['responsecode']} (#{doc['reason']})."
return []
end
end
......
{"bossresponse":{"responsecode":"6000","reason":"internal error"}}
......@@ -82,6 +82,14 @@ class ServicesTest < Test::Unit::TestCase
assert_equal [], Geocoder.search("no results")
end
def test_yahoo_error
Geocoder::Configuration.lookup = :yahoo
# keep test output clean: suppress timeout warning
orig = $VERBOSE; $VERBOSE = nil
assert_equal [], Geocoder.search("error")
$VERBOSE = orig
end
def test_yahoo_result_components
Geocoder::Configuration.lookup = :yahoo
result = Geocoder.search("madison square garden").first
......
......@@ -104,6 +104,7 @@ module Geocoder
raise SocketError if query.text == "socket_error"
file = case query.text
when "no results"; :no_results
when "error"; :error
else :madison_square_garden
end
read_fixture "yahoo_#{file}.json"
......
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