From 63cc3c195a03e469bc23b5bf2b60f4435c57c443 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sat, 7 Jan 2012 15:03:25 +0000 Subject: [PATCH] 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. --- app/controllers/application_controller.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 -- 2.43.2