Merge branch 'master' into openID
[rails.git] / config / initializers / abstract_adapter.rb
1 module 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("time's up!")
20         else
21           raise
22         end
23       end
24     end
25   end
26 end