Using an around_handler for catching and rendering errors in most of the API controller methods. This simplifies the code and makes errors and error messages a bit more consistent. Also added a utility method for checking the HTTP method.
This commit is contained in:
parent
058d942c7c
commit
3d0ca940d2
13 changed files with 311 additions and 444 deletions
12
lib/osm.rb
12
lib/osm.rb
|
@ -185,6 +185,18 @@ module OSM
|
|||
end
|
||||
end
|
||||
|
||||
##
|
||||
# raised when an API call is made using a method not supported on that URI
|
||||
class APIBadMethodError < APIError
|
||||
def initialize(supported_method)
|
||||
@supported_method = supported_method
|
||||
end
|
||||
|
||||
def render_opts
|
||||
{ :text => "Only method #{@supported_method} is supported on this URI.", :status => :method_not_allowed }
|
||||
end
|
||||
end
|
||||
|
||||
# Helper methods for going to/from mercator and lat/lng.
|
||||
class Mercator
|
||||
include Math
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue