]> git.openstreetmap.org Git - rails.git/blob - config/initializers/abstract_adapter.rb
Ever more tests...
[rails.git] / config / initializers / abstract_adapter.rb
1 if defined?(ActiveRecord::ConnectionAdaptors::AbstractAdapter)
2   module ActiveRecord
3     module ConnectionAdapters
4       class AbstractAdapter
5         protected
6
7         alias_method :old_log, :log
8
9         def log(sql, name)
10           if block_given?
11             old_log(sql, name) do
12               yield
13             end
14           else
15             old_log(sql, name)
16           end
17         rescue ActiveRecord::StatementInvalid => ex
18           if ex.message =~ /^OSM::APITimeoutError: /
19             raise OSM::APITimeoutError.new
20           elsif ex.message =~ /^Timeout::Error: /
21             raise Timeout::Error.new("time's up!")
22           else
23             raise
24           end
25         end
26       end
27     end
28   end
29 end