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

Merge pull request #423 from lukewendling/master

Yahoo auth errors: add raw message to warnings
parents fad62741 3861da95
No related branches found
No related tags found
No related merge requests found
......@@ -46,13 +46,15 @@ module Geocoder::Lookup
# Yahoo returns errors as XML even when JSON format is specified.
# Handle that here, without parsing the XML
# (which would add unnecessary complexity).
# Yahoo auth errors can also be cryptic, so add raw error desc
# to warning message.
#
def parse_raw_data(raw_data)
if raw_data.match /^<\?xml/
if raw_data.include?("Rate Limit Exceeded")
raise_error(Geocoder::OverQueryLimitError) || warn("Over API query limit.")
elsif raw_data.include?("Please provide valid credentials")
raise_error(Geocoder::InvalidApiKey) || warn("Invalid API key.")
elsif raw_data =~ /<yahoo:description>(Please provide valid credentials.*)<\/yahoo:description>/i
raise_error(Geocoder::InvalidApiKey) || warn("Invalid API key. Error response: #{$1}")
end
else
super(raw_data)
......
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