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:
Matt Amos 2009-05-20 17:39:59 +00:00
parent 058d942c7c
commit 3d0ca940d2
13 changed files with 311 additions and 444 deletions

View file

@ -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