File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,4 +37,7 @@ class LookupTimeout < ::Timeout::Error
3737 class NetworkError < Error
3838 end
3939
40+ class MethodNotAllowed < Error
41+ end
42+
4043end
Original file line number Diff line number Diff line change @@ -281,6 +281,9 @@ def check_response_for_errors!(response)
281281 elsif response . code . to_i == 402
282282 raise_error ( Geocoder ::OverQueryLimitError ) ||
283283 Geocoder . log ( :warn , "Geocoding API error: 402 Payment Required" )
284+ elsif response . code . to_i == 405
285+ raise_error ( Geocoder ::MethodNotAllowed ) ||
286+ Geocoder . log ( :warn , "Geocoding API error: 405 Method Not Allowed" )
284287 elsif response . code . to_i == 429
285288 raise_error ( Geocoder ::OverQueryLimitError ) ||
286289 Geocoder . log ( :warn , "Geocoding API error: 429 Too Many Requests" )
Original file line number Diff line number Diff line change @@ -48,4 +48,13 @@ def test_raises_exception_when_over_query_limit
4848 l . send ( :results , Geocoder ::Query . new ( "over limit" ) )
4949 end
5050 end
51+
52+ def test_raises_exception_when_method_not_allowed
53+ Geocoder . configure ( :always_raise => [ Geocoder ::MethodNotAllowed ] )
54+ l = Geocoder ::Lookup . get ( :nominatim )
55+ assert_raises Geocoder ::MethodNotAllowed do
56+ response = MockHttpResponse . new ( code : 405 )
57+ l . send ( :check_response_for_errors! , response )
58+ end
59+ end
5160end
You can’t perform that action at this time.
0 commit comments