From b5d8948875db179f18b5ca4d9580636f8a3afdbd Mon Sep 17 00:00:00 2001 From: Luke Wendling <luke@lukewendling.com> Date: Sat, 30 Mar 2013 20:17:34 -0500 Subject: [PATCH] add yahoo auth errors raw message to warnings --- lib/geocoder/lookups/yahoo.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/geocoder/lookups/yahoo.rb b/lib/geocoder/lookups/yahoo.rb index 0c27cc0c..501c4c75 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 =~ /\n(.*Please provide valid credentials.*)\n/ + raise_error(Geocoder::InvalidApiKey) || warn("Invalid API key. Error response: #{$1}") end else super(raw_data) -- GitLab