From 732895a8dc1867e89a3cc1167c877342822c096d Mon Sep 17 00:00:00 2001 From: Alex Reisner <alex@alexreisner.com> Date: Tue, 29 Nov 2011 13:05:02 -0500 Subject: [PATCH] Add OverQueryLimitError and raise for Google. --- lib/geocoder/exceptions.rb | 3 +++ lib/geocoder/lookups/google.rb | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/geocoder/exceptions.rb b/lib/geocoder/exceptions.rb index 0294c8d8..208ca979 100644 --- a/lib/geocoder/exceptions.rb +++ b/lib/geocoder/exceptions.rb @@ -5,4 +5,7 @@ module Geocoder class ConfigurationError < Error end + + class OverQueryLimitError < Error + end end diff --git a/lib/geocoder/lookups/google.rb b/lib/geocoder/lookups/google.rb index 9d039550..21ae3cfa 100644 --- a/lib/geocoder/lookups/google.rb +++ b/lib/geocoder/lookups/google.rb @@ -15,7 +15,8 @@ module Geocoder::Lookup case doc['status']; when "OK" # OK status implies >0 results return doc['results'] when "OVER_QUERY_LIMIT" - warn "Google Geocoding API error: over query limit." + raise_error(Geocoder::OverQueryLimitError) || + warn("Google Geocoding API error: over query limit.") when "REQUEST_DENIED" warn "Google Geocoding API error: request denied." when "INVALID_REQUEST" -- GitLab