X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/bed9cd00ed166ce346da4b8a9b654ddf86e64e70..bcbbf1944b55eb213a43d7d501533e65182c8f6a:/lib/osm.rb diff --git a/lib/osm.rb b/lib/osm.rb index f372979a8..0a62d14c0 100644 --- a/lib/osm.rb +++ b/lib/osm.rb @@ -13,6 +13,10 @@ module OSM def render_opts { :text => "Generic API Error", :status => :internal_server_error, :content_type => "text/plain" } end + + def to_s + "Generic API Error" + end end # Raised when an API object is not found. @@ -31,12 +35,22 @@ module OSM def render_opts { :text => "Precondition failed: #{@message}", :status => :precondition_failed, :content_type => "text/plain" } end + + def to_s + "Precondition failed: #{@message}" + end end # Raised when to delete an already-deleted object. class APIAlreadyDeletedError < APIError + def initialize(object = "object", object_id = "") + @object, @object_id = object, object_id + end + + attr_reader :object, :object_id + def render_opts - { :text => "The object has already been deleted", :status => :gone, :content_type => "text/plain" } + { :text => "The #{object} with the id #{object_id} has already been deleted", :status => :gone, :content_type => "text/plain" } end end @@ -65,6 +79,10 @@ module OSM def render_opts { :text => "You need to supply a changeset to be able to make a change", :status => :conflict, :content_type => "text/plain" } end + + def to_s + "You need to supply a changeset to be able to make a change" + end end # Raised when a diff is uploaded containing many changeset IDs which don't match @@ -119,6 +137,10 @@ module OSM ", server had: " + latest.to_s + " of " + type + " " + id.to_s, :status => :conflict, :content_type => "text/plain" } end + + def to_s + "Version mismatch: Provided " + provided.to_s + ", server had: " + latest.to_s + " of " + type + " " + id.to_s + end end # raised when a two tags have a duplicate key string in an element.