]> git.openstreetmap.org Git - rails.git/blobdiff - lib/osm.rb
Refine map UI for small screens
[rails.git] / lib / osm.rb
index ba28378f398c52610140cc6d04c6c2f3a0b1c492..4a6237b12b3dd8cd8c71fc8bf3f9ba5697dd97e7 100644 (file)
@@ -298,6 +298,23 @@ module OSM
     end
   end
 
+  # Raised when the note provided is already open
+  class APINoteAlreadyOpenError < APIError
+    def initialize(note)
+      @note = note
+    end
+
+    attr_reader :note
+
+    def status
+      :conflict
+    end
+
+    def to_s
+      "The note #{@note.id} is already open"
+    end
+  end
+
   # raised when a two preferences have a duplicate key string.
   class APIDuplicatePreferenceError < APIError
     def initialize(key)
@@ -533,6 +550,13 @@ module OSM
     return nil
   end
 
+  # Parse a float, raising a specified exception on failure
+  def self.parse_float(str, klass, *args)
+    Float(str)
+  rescue
+    raise klass.new(*args)
+  end
+
   # Construct a random token of a given length
   def self.make_token(length = 30)
     chars = 'abcdefghijklmnopqrtuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'