From 0afd326c364866108dedbae6b53537831478a34e Mon Sep 17 00:00:00 2001 From: Rob Sanheim Date: Tue, 1 Jul 2014 13:41:08 -0500 Subject: [PATCH] Move commit exception handling to a method so we can override It looks like these methods all get included into the AbstractAdapter, and then in github/github we have our own Adapter as an internal gem. So this should be easy enough to override in our vendor'ed adapter. This will allow us to still grab errors that happen in `after_commit` which would normally be swallowed in Rails 3.0 (and beyond). Conflicts: activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb --- .../connection_adapters/abstract/database_statements.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb index 2703c2ed70..bfa7748de1 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb @@ -371,7 +371,7 @@ module ActiveRecord begin record.committed! rescue Exception => e - record.logger.error(e) if record.respond_to?(:logger) && record.logger + handle_commit_exceptions(record, e) end end end @@ -385,6 +385,11 @@ module ActiveRecord row = result.rows.first row && row.first end + + # Handle any exceptions caught trying to send the commit message to a record + def handle_commit_exceptions(record, e) + record.logger.error(e) if record.respond_to?(:logger) && record.logger + end end end end