From 9301973d74c96c87c554566715b34e7dd852b7f4 Mon Sep 17 00:00:00 2001
From: Andy Kim <andy@verticalbrands.com>
Date: Thu, 26 Apr 2012 18:23:55 -0700
Subject: [PATCH] Raise exceptions for google REQUEST_DENIED and
 INVALID_REQUEST

---
 lib/geocoder/exceptions.rb     | 7 +++++++
 lib/geocoder/lookups/google.rb | 6 ++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/lib/geocoder/exceptions.rb b/lib/geocoder/exceptions.rb
index 208ca979..0ed0eb0d 100644
--- a/lib/geocoder/exceptions.rb
+++ b/lib/geocoder/exceptions.rb
@@ -8,4 +8,11 @@ module Geocoder
 
   class OverQueryLimitError < Error
   end
+
+  class RequestDenied < Error
+  end
+
+  class InvalidRequest < Error
+  end
+
 end
diff --git a/lib/geocoder/lookups/google.rb b/lib/geocoder/lookups/google.rb
index 21ae3cfa..6898c267 100644
--- a/lib/geocoder/lookups/google.rb
+++ b/lib/geocoder/lookups/google.rb
@@ -18,9 +18,11 @@ module Geocoder::Lookup
         raise_error(Geocoder::OverQueryLimitError) ||
           warn("Google Geocoding API error: over query limit.")
       when "REQUEST_DENIED"
-        warn "Google Geocoding API error: request denied."
+        raise_error(Geocoder::RequestDenied) ||
+          warn("Google Geocoding API error: request denied.")
       when "INVALID_REQUEST"
-        warn "Google Geocoding API error: invalid request."
+        raise_error(Geocoder::InvalidRequest) ||
+          warn("Google Geocoding API error: invalid request.")
       end
       return []
     end
-- 
GitLab