]> git.openstreetmap.org Git - rails.git/commitdiff
Error message for version mismatch is now more informative.
authorMatt Amos <zerebubuth@gmail.com>
Sat, 8 Nov 2008 14:07:34 +0000 (14:07 +0000)
committerMatt Amos <zerebubuth@gmail.com>
Sat, 8 Nov 2008 14:07:34 +0000 (14:07 +0000)
lib/consistency_validations.rb
lib/osm.rb

index 8fd6c257d732d30d219df8ac0e2df12185ab4ed2..6e214f90271a066b77a50873c19caddf6840cacd 100644 (file)
@@ -7,7 +7,7 @@ module ConsistencyValidations
   # This will throw an exception if there is an inconsistency
   def check_consistency(old, new, user)
     if new.version != old.version
-      raise OSM::APIVersionMismatchError.new(new.version, old.version)
+      raise OSM::APIVersionMismatchError.new(new.id, new.class.to_s, new.version, old.version)
     elsif new.changeset.nil?
       raise OSM::APIChangesetMissingError.new
     elsif new.changeset.user_id != user.id
index 223e351f4c60a0e4790a6d45ee89f36541ede7f9..c132ff25cfc4ef2bcffc40e84a3a714da36bea1b 100644 (file)
@@ -95,15 +95,16 @@ module OSM
 
   # Raised when the provided version is not equal to the latest in the db.
   class APIVersionMismatchError < APIError
-    def initialize(provided, latest)
-      @provided, @latest = provided, latest
+    def initialize(id, type, provided, latest)
+      @id, @type, @provided, @latest = id, type, provided, latest
     end
 
-    attr_reader :provided, :latest
+    attr_reader :provided, :latest, :id, :type
 
     def render_opts
       { :text => "Version mismatch: Provided " + provided.to_s +
-      ", server had: " + latest.to_s, :status => :conflict }
+        ", server had: " + latest.to_s + " of " + type + " " + id.to_s, 
+        :status => :conflict }
     end
   end