]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/node.rb
Actually set the instance var when closing the changeset
[rails.git] / app / models / node.rb
index e1ad818ddec0c53991690a3c52727d7a09af930f..e90c329507c9af7c244fe8129038fda103aa0099 100644 (file)
@@ -71,19 +71,21 @@ class Node < ActiveRecord::Base
       doc.find('//osm/node').each do |pt|
         return Node.from_xml_node(pt, create)
       end
-    rescue
-      return nil
+    rescue LibXML::XML::Error => ex
+      raise OSM::APIBadXMLError.new("node", xml, ex.message)
     end
   end
 
   def self.from_xml_node(pt, create=false)
     node = Node.new
     
+    raise OSM::APIBadXMLError.new("node", pt, "lat missing") if pt['lat'].nil?
+    raise OSM::APIBadXMLError.new("node", pt, "lon missing") if pt['lon'].nil?
     node.lat = pt['lat'].to_f
     node.lon = pt['lon'].to_f
     node.changeset_id = pt['changeset'].to_i
 
-    return nil unless node.in_world?
+    raise OSM::APIBadUserInput.new("The node is outside this world") unless node.in_world?
 
     # version must be present unless creating
     return nil unless create or not pt['version'].nil?
@@ -274,7 +276,7 @@ class Node < ActiveRecord::Base
 
     # duplicate tags are now forbidden, so we can't allow values
     # in the hash to be overwritten.
-    raise OSM::APIDuplicateTagsError.new if @tags.include? k
+    raise OSM::APIDuplicateTagsError.new("node", self.id, k) if @tags.include? k
 
     @tags[k] = v
   end