]> git.openstreetmap.org Git - rails.git/commitdiff
Try really hard to find out if the real exception was a timeout
authorTom Hughes <tom@compton.nu>
Sat, 7 Jan 2012 15:03:25 +0000 (15:03 +0000)
committerTom Hughes <tom@compton.nu>
Sat, 7 Jan 2012 15:03:25 +0000 (15:03 +0000)
Helpfully rails manages to wrap the actual exception that occurred
in at least one, and sometimes two further levels of exception, one
of which does preserve the original exception except as text.

app/controllers/application_controller.rb

index 74576555134e26a77040c95781fdfbac7158bc2c..a90a295fb35349c397784599a437ce5941ab45cf 100644 (file)
@@ -300,7 +300,13 @@ class ApplicationController < ActionController::Base
       yield
     end
   rescue ActionView::Template::Error => ex
-    if ex.original_exception.is_a?(Timeout::Error)
+    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