diff --git a/lib/geocoder/lookups/yahoo.rb b/lib/geocoder/lookups/yahoo.rb index 0c27cc0c77cde05e30c85c5a1adfae9852caa9ed..beff6c8830f352307e368610d64c4759253fd48f 100644 --- a/lib/geocoder/lookups/yahoo.rb +++ b/lib/geocoder/lookups/yahoo.rb @@ -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)