X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/86b4d1bc2c05a68053c7485217144a7fcf8ef4e8..2ff2cdf63d7f9874960c3efea01b4db2a80f9f68:/lib/osm.rb diff --git a/lib/osm.rb b/lib/osm.rb index a8cb103d2..38053e12a 100644 --- a/lib/osm.rb +++ b/lib/osm.rb @@ -10,6 +10,9 @@ module OSM # The base class for API Errors. class APIError < RuntimeError + def render_opts + { :text => "", :status => :internal_server_error } + end end # Raised when an API object is not found. @@ -18,10 +21,16 @@ module OSM # Raised when a precondition to an API action fails sanity check. class APIPreconditionFailedError < APIError + def render_opts + { :text => "", :status => :precondition_failed } + end end # Raised when to delete an already-deleted object. class APIAlreadyDeletedError < APIError + def render_opts + { :text => "", :status => :gone } + end end # Raised when the provided version is not equal to the latest in the db. @@ -31,6 +40,11 @@ module OSM end attr_reader :provided, :latest + + def render_opts + { :text => "Version mismatch: Provided " + ex.provided.to_s + + ", server had: " + ex.latest.to_s, :status => :bad_request } + end end # Helper methods for going to/from mercator and lat/lng.