]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/application_controller.rb
Revert "Log locale selection"
[rails.git] / app / controllers / application_controller.rb
index 96bf915c0f9e3034fe9c0cb2029c1feb8ae1861b..a90a295fb35349c397784599a437ce5941ab45cf 100644 (file)
@@ -286,7 +286,7 @@ class ApplicationController < ActionController::Base
   ##
   # wrap an api call in a timeout
   def api_call_timeout
   ##
   # wrap an api call in a timeout
   def api_call_timeout
-    SystemTimer.timeout_after(API_TIMEOUT) do
+    OSM::Timer.timeout(API_TIMEOUT) do
       yield
     end
   rescue Timeout::Error
       yield
     end
   rescue Timeout::Error
@@ -296,11 +296,17 @@ class ApplicationController < ActionController::Base
   ##
   # wrap a web page in a timeout
   def web_timeout
   ##
   # wrap a web page in a timeout
   def web_timeout
-    SystemTimer.timeout_after(WEB_TIMEOUT) do
+    OSM::Timer.timeout(WEB_TIMEOUT) do
       yield
     end
       yield
     end
-  rescue ActionView::TemplateError => ex
-    if ex.original_exception.is_a?(Timeout::Error)
+  rescue ActionView::Template::Error => ex
+    ex = ex.original_exception
+
+    if ex.is_a?(ActiveRecord::StatementInvalid) and ex.message =~ /^Timeout::Error/
+      ex = Timeout::Error.new
+    end
+
+    if ex.is_a?(Timeout::Error)
       render :action => "timeout"
     else
       raise
       render :action => "timeout"
     else
       raise