Improve the node/way/relation already deleted error message, and get rid bug in way...
authorShaun McDonald <shaun@shaunmcdonald.me.uk>
Mon, 27 Apr 2009 11:49:56 +0000 (11:49 +0000)
committerShaun McDonald <shaun@shaunmcdonald.me.uk>
Mon, 27 Apr 2009 11:49:56 +0000 (11:49 +0000)
app/models/node.rb
app/models/relation.rb
app/models/way.rb
lib/osm.rb

index e7356085f605c958d68f9503e1f6a2104f409ad0..d5967c2fa1caab02bcd54dbc1b8f0380b7eac075 100644 (file)
@@ -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 
index 8a211b84f0498888108754c4b2e1bc70032a906c..4e75eed357a4df79c9df6afacb2cac06d1ee4e17 100644 (file)
@@ -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 
index 637f41e2883580c83b3385ac7db162ead4493a24..2b6f562be6c2fbbc95c290a70a4728d701dc2c5e 100644 (file)
@@ -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 
index eb5afd5623f68659849e31131289469ddf73d61f..0a62d14c0c77890ea67a634db4d0ceb5e6a82700 100644 (file)
@@ -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