From: Shaun McDonald Date: Mon, 27 Apr 2009 11:49:56 +0000 (+0000) Subject: Improve the node/way/relation already deleted error message, and get rid bug in way... X-Git-Tag: live~7475 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/0b6d9ce877a08cb762b5d9354847187c6b43e216 Improve the node/way/relation already deleted error message, and get rid bug in way model with missing new in exception --- diff --git a/app/models/node.rb b/app/models/node.rb index e7356085f..d5967c2fa 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -123,7 +123,7 @@ class Node < ActiveRecord::Base # Should probably be renamed delete_from to come in line with update def delete_with_history!(new_node, user) unless self.visible - raise OSM::APIAlreadyDeletedError.new + raise OSM::APIAlreadyDeletedError.new("node", new_node.id) end # need to start the transaction here, so that the database can diff --git a/app/models/relation.rb b/app/models/relation.rb index 8a211b84f..4e75eed35 100644 --- a/app/models/relation.rb +++ b/app/models/relation.rb @@ -227,7 +227,7 @@ class Relation < ActiveRecord::Base def delete_with_history!(new_relation, user) unless self.visible - raise OSM::APIAlreadyDeletedError.new + raise OSM::APIAlreadyDeletedError.new("relation", new_relation.id) end # need to start the transaction here, so that the database can diff --git a/app/models/way.rb b/app/models/way.rb index 637f41e28..2b6f562be 100644 --- a/app/models/way.rb +++ b/app/models/way.rb @@ -237,7 +237,7 @@ class Way < ActiveRecord::Base def delete_with_history!(new_way, user) unless self.visible - raise OSM::APIAlreadyDeletedError + raise OSM::APIAlreadyDeletedError.new("way", new_way.id) end # need to start the transaction here, so that the database can diff --git a/lib/osm.rb b/lib/osm.rb index eb5afd562..0a62d14c0 100644 --- a/lib/osm.rb +++ b/lib/osm.rb @@ -43,8 +43,14 @@ module OSM # 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