diff --git a/lib/geocoder/lookups/base.rb b/lib/geocoder/lookups/base.rb index 8e58c4511f5c6e9830ed8094b46386378b162203..1d6e164c45bb3267aa467c3416cd62b765847e3d 100644 --- a/lib/geocoder/lookups/base.rb +++ b/lib/geocoder/lookups/base.rb @@ -106,29 +106,25 @@ module Geocoder # Returns a parsed search result (Ruby hash). # def fetch_data(query, reverse = false) - begin - parse_raw_data fetch_raw_data(query, reverse) - rescue SocketError => err - raise_error(err) or warn "Geocoding API connection cannot be established." - rescue TimeoutError => err - raise_error(err) or warn "Geocoding API not responding fast enough " + - "(see Geocoder::Configuration.timeout to set limit)." - end + parse_raw_data fetch_raw_data(query, reverse) + rescue SocketError => err + raise_error(err) or warn "Geocoding API connection cannot be established." + rescue TimeoutError => err + raise_error(err) or warn "Geocoding API not responding fast enough " + + "(see Geocoder::Configuration.timeout to set limit)." end ## # Parses a raw search result (returns hash or array). # def parse_raw_data(raw_data) - begin - if defined?(ActiveSupport::JSON) - ActiveSupport::JSON.decode(raw_data) - else - JSON.parse(raw_data) - end - rescue - warn "Geocoding API's response was not valid JSON." + if defined?(ActiveSupport::JSON) + ActiveSupport::JSON.decode(raw_data) + else + JSON.parse(raw_data) end + rescue + warn "Geocoding API's response was not valid JSON." end ## diff --git a/lib/geocoder/models/mongo_base.rb b/lib/geocoder/models/mongo_base.rb index 15bbbabe848b51c99247c2339dae34b764f45b1a..58cad07aacc7b3524b4c2b5dd2834a9972d96e6f 100644 --- a/lib/geocoder/models/mongo_base.rb +++ b/lib/geocoder/models/mongo_base.rb @@ -44,11 +44,9 @@ module Geocoder end def geocoder_initialized? - begin - included_modules.include? Geocoder::Store.const_get(geocoder_module_name) - rescue NameError - false - end + included_modules.include? Geocoder::Store.const_get(geocoder_module_name) + rescue NameError + false end end end