From 8edcaa3b831ab40ea5c8ef18446c6153fd95456d Mon Sep 17 00:00:00 2001 From: Alex Reisner <alex@alexreisner.com> Date: Tue, 8 Feb 2011 10:43:47 -0500 Subject: [PATCH] Issue warning on Google API quota error. --- README.rdoc | 5 +---- lib/geocoder/lookup.rb | 7 ++++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.rdoc b/README.rdoc index c8dbb6e9..29a71661 100644 --- a/README.rdoc +++ b/README.rdoc @@ -175,10 +175,7 @@ If anyone has a more elegant solution to this problem I am very interested in se == To-do List -* handle OVER_QUERY_LIMIT error - * raise exception? maybe only when address! or search! is called - * print warning? -* support DataMapper, Mongoid, etc +* support different ORMs (DataMapper, Mongoid, etc) * use completely separate "drivers" for different AR adapters? * seems reasonable since we're using very DB-specific features * also need to make sure 'mysql2' is supported diff --git a/lib/geocoder/lookup.rb b/lib/geocoder/lookup.rb index 443c5cc0..5e5a771a 100644 --- a/lib/geocoder/lookup.rb +++ b/lib/geocoder/lookup.rb @@ -49,7 +49,11 @@ module Geocoder def parsed_response(query, reverse = false) if doc = fetch_data(query, reverse) doc = ActiveSupport::JSON.decode(doc) - doc && doc['status'] == "OK" ? doc : nil + if doc && doc['status'] == "OK" + return doc + elsif doc['status'] == "OVER_QUERY_LIMIT" + warn "Google Geocoder API error: quota exceeded." + end end end @@ -78,3 +82,4 @@ module Geocoder end end end + -- GitLab