]> git.openstreetmap.org Git - rails.git/blobdiff - lib/osm.rb
Merge remote-tracking branch 'upstream/master' into routing
[rails.git] / lib / osm.rb
index 9e819829921f68f0b8b74c5a70f4b407b6cf0570..c59ab7e262cc60ee87dbe0452efa170cce10b400 100644 (file)
@@ -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