From: Tom Hughes Date: Sat, 7 Jan 2012 15:03:25 +0000 (+0000) Subject: Try really hard to find out if the real exception was a timeout X-Git-Tag: live~5919 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/63cc3c195a03e469bc23b5bf2b60f4435c57c443 Try really hard to find out if the real exception was a timeout 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. --- diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 745765551..a90a295fb 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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