From: Tom Hughes Date: Thu, 21 May 2009 09:57:21 +0000 (+0000) Subject: Monkey patch rails to ensure OSM::APITimeoutError exceptions are not lost. X-Git-Tag: live~7399 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/e3cbeeae9453a0108733316e5119d0038abab760?hp=8100be1e8db3017fe42c7785c391d73e0aff7992 Monkey patch rails to ensure OSM::APITimeoutError exceptions are not lost. --- diff --git a/config/initializers/abstract_adapter.rb b/config/initializers/abstract_adapter.rb new file mode 100644 index 000000000..7b22a3cc6 --- /dev/null +++ b/config/initializers/abstract_adapter.rb @@ -0,0 +1,24 @@ +module ActiveRecord + module ConnectionAdapters + class AbstractAdapter + protected + alias_method :old_log, :log + + def log(sql, name) + if block_given? + old_log(sql, name) do + yield + end + else + old_log(sql, name) + end + rescue ActiveRecord::StatementInvalid => ex + if ex =~ /^OSM::APITimeoutError: / + raise OSM::APITimeoutError + else + raise + end + end + end + end +end