Fixed problem where tag lengths were generating a 422 error with no message. They now generate a 400 error with a meaningful message.

This commit is contained in:
Matt Amos 2009-05-10 00:33:55 +00:00
parent 69c2400997
commit b7f306a437
6 changed files with 57 additions and 1 deletions

View file

@ -254,6 +254,11 @@ class Node < ActiveRecord::Base
# in the hash to be overwritten.
raise OSM::APIDuplicateTagsError.new("node", self.id, k) if @tags.include? k
# check tag size here, as we don't create a NodeTag object until
# just before we save...
raise OSM::APIBadUserInput.new("Node #{self.id} has a tag with too long a key, '#{k}'.") if k.length > 255
raise OSM::APIBadUserInput.new("Node #{self.id} has a tag with too long a value, '#{k}'='#{v}'.") if v.length > 255
@tags[k] = v
end

View file

@ -218,6 +218,11 @@ class Relation < ActiveRecord::Base
# in the hash to be overwritten.
raise OSM::APIDuplicateTagsError.new("relation", self.id, k) if @tags.include? k
# check tag size here, as we don't create a RelationTag object until
# just before we save...
raise OSM::APIBadUserInput.new("Relation #{self.id} has a tag with too long a key, '#{k}'.") if k.length > 255
raise OSM::APIBadUserInput.new("Relation #{self.id} has a tag with too long a value, '#{k}'='#{v}'.") if v.length > 255
@tags[k] = v
end

View file

@ -191,6 +191,11 @@ class Way < ActiveRecord::Base
# in the hash to be overwritten.
raise OSM::APIDuplicateTagsError.new("way", self.id, k) if @tags.include? k
# check tag size here, as we don't create a WayTag object until
# just before we save...
raise OSM::APIBadUserInput.new("Way #{self.id} has a tag with too long a key, '#{k}'.") if k.length > 255
raise OSM::APIBadUserInput.new("Way #{self.id} has a tag with too long a value, '#{k}'='#{v}'.") if v.length > 255
@tags[k] = v
end