From 62e1a5ecb05add00d9de4b227817d5abe124d752 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 1 Jun 2014 10:31:28 +0200 Subject: [PATCH] Improved error handling. --- lib/geo_location/gmaps.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/geo_location/gmaps.rb b/lib/geo_location/gmaps.rb index c286c9820..4d09f3f81 100644 --- a/lib/geo_location/gmaps.rb +++ b/lib/geo_location/gmaps.rb @@ -9,6 +9,10 @@ class GeoLocation::Gmaps result = JSON.parse( response.body ) + return if !result + return if !result['results'] + return if !result['results'].first + lat = result['results'].first['geometry']['location']['lat'] lng = result['results'].first['geometry']['location']['lng'] latlng = [lat,lng]