X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/c809f79912a3b998ddf3a21973582254db564183..669d3ed52c6f22e842c1319c242e06ee9694f615:/lib/osm.rb diff --git a/lib/osm.rb b/lib/osm.rb index ba28378f3..4a6237b12 100644 --- a/lib/osm.rb +++ b/lib/osm.rb @@ -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'