From 87452465aad6ed44fa6786172cd803ced0d8c56c Mon Sep 17 00:00:00 2001
From: Alex Reisner <alex@alexreisner.com>
Date: Tue, 21 Apr 2009 10:38:08 -0400
Subject: [PATCH] Improve error handling when geocoder unavailable.

---
 lib/geocoder.rb | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/geocoder.rb b/lib/geocoder.rb
index 2b9912ad..647fb044 100644
--- a/lib/geocoder.rb
+++ b/lib/geocoder.rb
@@ -14,7 +14,11 @@ module Geocoder
     data = self.search(query)
     
     # Make sure search found a result.
-    return nil unless data['kml']['response']['status']['code'] == "200"
+    unless data and data['kml']['response']['status']['code'] == "200"
+      return nil
+    end
+    
+    # Isolate the relevant part of the result.
     place = data['kml']['response']['placemark']
 
     # If there are multiple results, blindly use the first.
-- 
GitLab