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.
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