X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/40b452ac7431387979fa2c2cdd2565bae5993f29..a3eb48385bcf1465339d473c0c1657e075cd507d:/lib/osm.rb diff --git a/lib/osm.rb b/lib/osm.rb index a2432c1e6..c59ab7e26 100644 --- a/lib/osm.rb +++ b/lib/osm.rb @@ -24,6 +24,17 @@ module OSM end end + # Raised when access is denied. + class APIAccessDenied < RuntimeError + def status + :forbidden + end + + def to_s + "Access denied" + end + end + # Raised when an API object is not found. class APINotFoundError < APIError def status @@ -95,6 +106,57 @@ module OSM end end + # Raised when the changeset provided is not yet closed + class APIChangesetNotYetClosedError < APIError + def initialize(changeset) + @changeset = changeset + end + + attr_reader :changeset + + def status + :conflict + end + + def to_s + "The changeset #{@changeset.id} is not yet closed." + end + end + + # Raised when a user is already subscribed to the changeset + class APIChangesetAlreadySubscribedError < APIError + def initialize(changeset) + @changeset = changeset + end + + attr_reader :changeset + + def status + :conflict + end + + def to_s + "You are already subscribed to changeset #{@changeset.id}." + end + end + + # Raised when a user is not subscribed to the changeset + class APIChangesetNotSubscribedError < APIError + def initialize(changeset) + @changeset = changeset + end + + attr_reader :changeset + + def status + :not_found + end + + def to_s + "You are not subscribed to changeset #{@changeset.id}." + end + end + # Raised when a change is expecting a changeset, but the changeset doesn't exist class APIChangesetMissingError < APIError def status @@ -399,7 +461,7 @@ module OSM begin lonradius = 2 * asin(sqrt(sin(radius / 6372.795 / 2) ** 2 / cos(@lat) ** 2)) - rescue Errno::EDOM + rescue Errno::EDOM, Math::DomainError lonradius = PI end