X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/77797b21b0701654f9a7ee57aace7fa16214e9c2..9143fd61e8ae268ec40837efdb2b7cae49783b4d:/lib/osm.rb diff --git a/lib/osm.rb b/lib/osm.rb index 65eab6907..6710ee88e 100644 --- a/lib/osm.rb +++ b/lib/osm.rb @@ -8,7 +8,7 @@ module OSM # The base class for API Errors. class APIError < RuntimeError def initialize(message = "Generic API Error") - super(message) + super end def status @@ -51,14 +51,14 @@ module OSM # Raised when to delete an already-deleted object. class APIAlreadyDeletedError < APIError - def initialize(object = "object", object_id = "") - @object = object - @object_id = object_id + def initialize(type = "object", id = "") + @type = type + @id = id - super("The #{object} with the id #{object_id} has already been deleted") + super("The #{type} with the id #{id} has already been deleted") end - attr_reader :object, :object_id + attr_reader :type, :id def status :gone @@ -364,6 +364,17 @@ module OSM end end + # Raised when a size limit is exceeded + class APISizeLimitExceeded < APIError + def initialize + super("Size limit exceeded") + end + + def status + :payload_too_large + end + end + # Helper methods for going to/from mercator and lat/lng. class Mercator include Math @@ -524,7 +535,8 @@ module OSM # Return the HTTP client to use def self.http_client - @http_client ||= Faraday.new(:request => { :timeout => 15 }) + @http_client ||= Faraday.new(:request => { :timeout => 15 }, + :headers => { :user_agent => Settings.server_url }) end # Return the MaxMindDB database handle