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