API v0.6/APIError

From OpenStreetMap Wiki
Jump to navigation Jump to search

This page was set up to collect information about errors that might be returned by the API and to develop a format for structured error messages to be returned by the API. This should help to make error handling in applications more reliable.


APIError

The base class for API errors.

APIAlreadyDeletedError

Raised when an attempt is made to delete an already-deleted object.

"The #{object} with the id #{object_id} has already been deleted"
  • #{object} is either node, way or relation
  • #{object_id} is the ID of the object

APIBadBoundingBox

Raised when bounding box is invalid.

"The minimum longitude must be less than the maximum longitude, but it wasn't"
"The minimum latitude must be less than the maximum latitude, but it wasn't"
"The latitudes must be between -90 and 90, and longitudes between -180 and 180"
"The maximum bbox size is #{max_request_area}, and your request was too large. Either request a smaller area, or use planet.osm"
  • #{max_request_area} is the largest area that may be requested from API

APIBadMethodError

Raised when an API call is made using a method not supported on that URI.

"Only method #{@supported_method} is supported on this URI"
  • #{@supported_method} can currently either be put or post

APIBadUserInput

Raised when user input couldn't be parsed.

from app/controllers/changeset_controller.rb:

"Bounding box should be min_lon,min_lat,max_lon,max_lat"
"Minimum longitude should be less than maximum."
"Minimum latitude should be less than maximum."
"provide either the user ID or display name, but not both"
"invalid user ID"
"bad time range"

 or whatever exception is thrown by DateTime.parse()

from app/controllers/node_controller.rb:

"The id in the url (#{node.id}) is not the same as provided in the xml (#{new_node.id})"
"No nodes were given to search for"

from app/models/relation.rb:

"ID of relation cannot be zero when updating."
"Some bad xml in relation"
"Placeholder #{type} not found for reference #{old_id} in relation #{self.id.nil? ? placeholder_id : self.id}."

The latter applies when a relation references a new object (ID < 0) which is not in the data.

from app/models/way.rb:

"ID of way cannot be zero when updating."
"Placeholder node not found for reference #{node_id} in way #{self.id.nil? ? placeholder_id : self.id}"

The latter applies when a way references a new node (ID < 0) which is not in the data.

from app/models/node.rb:

"The node is outside this world"
"ID of node cannot be zero when updating."

from lib/diff_reader.rb:

"Unexpected element type #{model_name}, expected node, way or relation."
"Document element should be 'osmChange'."
"Placeholder IDs must be unique for created elements."

APIBadXMLError

Raised when bad XML is encountered which stops things parsing as they should.

"Cannot parse valid #{@model} from xml string #{@xml}. #{@message}"
  • #{@model} can be changeset, node, way, relation or preferences
  • #{@xml} is the offending XML string
  • #{@message} can be:
"XML doesn't contain an osm/changeset element."
"tag is missing key"
"tag is missing value"
"XML doesn't contain an osm/relation element."
"Version is required when updating"
"Changeset id is missing"
"ID is required when updating"
"The #{member['type']} is not allowed only, #{TYPES.inspect} allowed"
"XML doesn't contain an osm/way element."
"XML doesn't contain an osm/node element."
"lat missing"
"lon missing"
"ID attribute is required"

or whatever error message is returned by the XML parser

APIChangesetActionInvalid

Raised when a diff upload has an unknown action. You can only have create, modify, or delete.

"Unknown action #{@provided}, choices are create, modify, delete"

APIChangesetAlreadyClosedError

Raised when the changeset provided is already closed.

"The changeset #{@changeset.id} was closed at #{@changeset.closed_at}"

APIChangesetMismatchError

Raised when a diff is uploaded containing many changeset IDs which don't match the changeset ID that the diff was uploaded to.

"Changeset mismatch: Provided #{@provided} but only #{@allowed} is allowed"

APIChangesetMissingError

Raised when a change is expecting a changeset, but the changeset doesn't exist.

"You need to supply a changeset to be able to make a change"

APIDuplicateTagsError

Raised when a two tags have a duplicate key string in an element. This is now forbidden by the API.

"Element #{@type}/#{@id} has duplicate tags with key #{@tag_key}"

APINotFoundError

This is raised when an API object was not found.

"Object not found"

This is currently only sent when a user is not found.

APIPreconditionFailedError

This is raised when a precondition to an API action fails sanity check.

"Precondition failed: #{@message}"

where #{@message} can be one of the following:

"Cannot create relation: data or member data is invalid."
"Cannot create way: data is invalid."
"Cannot update relation #{self.id}: data or member data is invalid."
"Cannot update way #{self.id}: data is invalid."
"Node #{self.id} is still used by relations #{rels.collect { |r| r.id }.join(",")}."
"Node #{self.id} is still used by ways #{ways.collect { |w| w.id }.join(",")}."
"Relation with id #{self.id} cannot be saved due to #{m[0]} with id #{m[1]}"
"The relation #{new_relation.id} is used in relation #{rel.relation.id}."
"Way #{self.id} is still used by relations #{rels.collect { |r| r.id }.join(",")}."
"Way #{self.id} requires the nodes with id in (#{missing.join(',')}), which either do not exist, or are not visible."


APITimeoutError

Raised when an API call takes too long.

"Request timed out"

APITooManyWayNodesError

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.

"You tried to add #{provided} nodes to way #{id}, however only #{max} are allowed"

APIUserChangesetMismatchError

Raised when the user logged in isn't the same as the changeset.

"The user doesn't own that changeset"

APIVersionMismatchError

Raised when the provided version is not equal to the latest in the db.

"Version mismatch: Provided #{provided}, server had: #{latest} of #{type} #{id}"