- def initialize(provided, max)
- @provided, @max = provided, max
+ def initialize(id, provided, max)
+ @id, @provided, @max = id, provided, max
+ end
+
+ attr_reader :id, :provided, :max
+
+ def status
+ :bad_request
+ end
+
+ def to_s
+ "You tried to add #{provided} nodes to way #{id}, however only #{max} are allowed"
+ end
+ end
+
+ ##
+ # raised when user input couldn't be parsed
+ class APIBadUserInput < APIError
+ def initialize(message)
+ @message = message
+ end
+
+ def status
+ :bad_request
+ end
+
+ def to_s
+ @message
+ end
+ end
+
+ ##
+ # raised when bounding box is invalid
+ class APIBadBoundingBox < APIError
+ def initialize(message)
+ @message = message
+ end
+
+ def status
+ :bad_request
+ end
+
+ def to_s
+ @message
+ end
+ end
+
+ ##
+ # raised when an API call is made using a method not supported on that URI
+ class APIBadMethodError < APIError
+ def initialize(supported_method)
+ @supported_method = supported_method
+ end
+
+ def status
+ :method_not_allowed
+ end
+
+ def to_s
+ "Only method #{@supported_method} is supported on this URI"
+ end
+ end
+
+ ##
+ # raised when an API call takes too long
+ class APITimeoutError < APIError
+ def status
+ :request_timeout
+ end
+
+ def to_s
+ "Request timed out"
+ end
+ end
+
+ ##
+ # raised when someone tries to redact a current version of
+ # an element - only historical versions can be redacted.
+ class APICannotRedactError < APIError
+ def status
+ :bad_request