+ ", server had: " + latest.to_s + " of " + type + " " + id.to_s,
+ :status => :conflict, :content_type => "text/plain" }
+ end
+
+ def to_s
+ "Version mismatch: Provided " + provided.to_s + ", server had: " + latest.to_s + " of " + type + " " + id.to_s
+ end
+ end
+
+ # raised when a two tags have a duplicate key string in an element.
+ # this is now forbidden by the API.
+ class APIDuplicateTagsError < APIError
+ def initialize(type, id, tag_key)
+ @type, @id, @tag_key = type, id, tag_key
+ end
+
+ attr_reader :type, :id, :tag_key
+
+ def render_opts
+ { :text => "Element #{@type}/#{@id} has duplicate tags with key #{@tag_key}.",
+ :status => :bad_request, :content_type => "text/plain" }
+ end
+ end
+
+ # Raised when a way has more than the configured number of way nodes.
+ # This prevents ways from being to long and difficult to work with
+ class APITooManyWayNodesError < APIError
+ def initialize(provided, max)
+ @provided, @max = provided, max
+ end
+
+ attr_reader :provided, :max
+
+ def render_opts
+ { :text => "You tried to add #{provided} nodes to the way, however only #{max} are allowed",
+ :status => :bad_request, :content_type => "text/plain" }
+ end
+ end
+
+ ##
+ # raised when user input couldn't be parsed
+ class APIBadUserInput < APIError
+ def initialize(message)
+ @message = message
+ end
+
+ def render_opts
+ { :text => @message, :content_type => "text/plain", :status => :bad_request }