]> git.openstreetmap.org Git - rails.git/blobdiff - lib/osm.rb
Potlatch 1.0
[rails.git] / lib / osm.rb
index a392b88a825f54b5b0963b3c97437c8aaf16221b..885d1e35821961d998e85bf78e75eff081a9ff57 100644 (file)
@@ -133,13 +133,12 @@ module OSM
     attr_reader :provided, :latest, :id, :type
 
     def render_opts
-      { :text => "Version mismatch: Provided " + provided.to_s +
-        ", server had: " + latest.to_s + " of " + type + " " + id.to_s, 
+      { :text => "Version mismatch: Provided #{provided}, server had: #{latest} of #{type} #{id}",
         :status => :conflict, :content_type => "text/plain" }
     end
     
     def to_s
-       "Version mismatch: Provided " + provided.to_s + ", server had: " + latest.to_s + " of " + type + " " + id.to_s
+       "Version mismatch: Provided #{provided}, server had: #{latest} of #{type} #{id}"
     end
   end
 
@@ -185,6 +184,30 @@ module OSM
     end
   end
 
+  ##
+  # raised when an API call is made using a method not supported on that URI
+  class APIBadMethodError < APIError
+    def initialize(supported_method)
+      @supported_method = supported_method
+    end
+
+    def render_opts
+      { :text => "Only method #{@supported_method} is supported on this URI.", :status => :method_not_allowed }
+    end
+  end
+
+  ##
+  # raised when an API call takes too long
+  class APITimeoutError < APIError
+    def render_opts
+      { :text => "Request timed out", :status => :request_timeout }
+    end
+
+    def to_s
+      "Request timed out"
+    end
+  end
+
   # Helper methods for going to/from mercator and lat/lng.
   class Mercator
     include Math