Skip to content
Snippets Groups Projects
Commit cfff7d18 authored by Alex Reisner's avatar Alex Reisner
Browse files

Move exceptions into Geocoder module.

parent c4256232
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,10 @@ module Geocoder
def search(*args)
Lookup.search(*args)
end
# exception classes
class Error < StandardError; end
class ConfigurationError < Error; end
end
......@@ -59,9 +63,3 @@ ActiveRecord::Base.class_eval do
end
end
class GeocoderError < StandardError
end
class GeocoderConfigurationError < GeocoderError
end
......@@ -185,7 +185,7 @@ module Geocoder
def fetch_coordinates(save = false)
address_method = self.class.geocoder_options[:user_address]
unless address_method.is_a? Symbol
raise GeocoderConfigurationError,
raise Geocoder::ConfigurationError,
"You are attempting to fetch coordinates but have not specified " +
"a method which provides an address for the object."
end
......@@ -213,7 +213,7 @@ module Geocoder
lat_attr = self.class.geocoder_options[:latitude]
lon_attr = self.class.geocoder_options[:longitude]
unless lat_attr.is_a?(Symbol) and lon_attr.is_a?(Symbol)
raise GeocoderConfigurationError,
raise Geocoder::ConfigurationError,
"You are attempting to fetch an address but have not specified " +
"attributes which provide coordinates for the object."
end
......
......@@ -23,7 +23,7 @@ class GeocoderTest < Test::Unit::TestCase
def test_exception_raised_for_unconfigured_geocoding
l = Landmark.new("Mount Rushmore", 43.88, -103.46)
assert_raises GeocoderConfigurationError do
assert_raises Geocoder::ConfigurationError do
l.fetch_coordinates
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment