Monkey patch rails to ensure OSM::APITimeoutError exceptions are not lost.
This commit is contained in:
parent
8100be1e8d
commit
e3cbeeae94
1 changed files with 24 additions and 0 deletions
24
config/initializers/abstract_adapter.rb
Normal file
24
config/initializers/abstract_adapter.rb
Normal file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue