We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5b15109 commit dc31352Copy full SHA for dc31352
lib/opencage/geocoder.rb
@@ -13,6 +13,8 @@ def initialize(default_options = {})
13
end
14
15
def geocode(location, options = {})
16
+ raise_error("400 not a valid location: `#{location.inspect}`") unless location.is_a?(String)
17
+
18
request = Request.new(@api_key, location, options)
19
20
begin
spec/open_cage/geocoder_spec.rb
@@ -82,6 +82,12 @@ def geo
82
it 'empty list when no results are found', :vcr do
83
expect(geo.geocode('NOWHERE-INTERESTING')).to eql([])
84
85
86
+ it 'throws a useful error when the query is not a string' do
87
+ expect do
88
+ geo.geocode({ query: 'NOT-A-STRING' })
89
+ end.to raise_error(OpenCage::Error::InvalidRequest)
90
+ end
91
92
93
describe 'user agent' do
0 commit comments