source: subversion/sites/rails_port/config/initializers/abstract_adapter.rb @ 19403

Last change on this file since 19403 was 19403, checked in by tomhughes, 10 years ago

Handle Timeout::Error exceptions which are caught by ActiveRecord?.

File size: 584 bytes
Line 
1module ActiveRecord
2  module ConnectionAdapters
3    class AbstractAdapter
4    protected
5      alias_method :old_log, :log
6
7      def log(sql, name)
8        if block_given?
9          old_log(sql, name) do
10            yield
11          end
12        else
13          old_log(sql, name)
14        end
15      rescue ActiveRecord::StatementInvalid => ex
16        if ex.message =~ /^OSM::APITimeoutError: /
17          raise OSM::APITimeoutError.new
18        elsif ex.message =~ /^Timeout::Error: /
19          raise Timeout::Error.new
20        else
21          raise
22        end
23      end
24    end
25  end
26end
Note: See TracBrowser for help on using the repository browser.