aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/transactions.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-01-04 11:23:57 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-01-04 11:58:44 -0300
commit07d3d402341e81ada0214f2cb2be1da69eadfe72 (patch)
tree8f75557a4144e685daa1befe8797511e2d80eb5d /activerecord/lib/active_record/transactions.rb
parent3a59dd212315ebb9bae8338b98af259ac00bbef3 (diff)
downloadrails-07d3d402341e81ada0214f2cb2be1da69eadfe72.tar.gz
rails-07d3d402341e81ada0214f2cb2be1da69eadfe72.tar.bz2
rails-07d3d402341e81ada0214f2cb2be1da69eadfe72.zip
Change transaction callbacks to not swallowing errors.
Before this change any error raised inside a transaction callback are rescued and printed in the logs. Now these errors are not rescue anymore and just bubble up, as the other callbacks.
Diffstat (limited to 'activerecord/lib/active_record/transactions.rb')
-rw-r--r--activerecord/lib/active_record/transactions.rb29
1 files changed, 10 insertions, 19 deletions
diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb
index 31ca90fb58..1c48196762 100644
--- a/activerecord/lib/active_record/transactions.rb
+++ b/activerecord/lib/active_record/transactions.rb
@@ -4,23 +4,10 @@ module ActiveRecord
extend ActiveSupport::Concern
#:nodoc:
ACTIONS = [:create, :destroy, :update]
- #:nodoc:
- CALLBACK_WARN_MESSAGE = "Currently, Active Record suppresses errors raised " \
- "within `after_rollback`/`after_commit` callbacks and only print them to " \
- "the logs. In the next version, these errors will no longer be suppressed. " \
- "Instead, the errors will propagate normally just like in other Active " \
- "Record callbacks.\n" \
- "\n" \
- "You can opt into the new behavior and remove this warning by setting:\n" \
- "\n" \
- " config.active_record.raise_in_transactional_callbacks = true\n\n"
included do
define_callbacks :commit, :rollback,
scope: [:kind, :name]
-
- mattr_accessor :raise_in_transactional_callbacks, instance_writer: false
- self.raise_in_transactional_callbacks = false
end
# = Active Record Transactions
@@ -236,9 +223,6 @@ module ActiveRecord
def after_commit(*args, &block)
set_options_for_callbacks!(args)
set_callback(:commit, :after, *args, &block)
- unless ActiveRecord::Base.raise_in_transactional_callbacks
- ActiveSupport::Deprecation.warn(CALLBACK_WARN_MESSAGE)
- end
end
# This callback is called after a create, update, or destroy are rolled back.
@@ -247,9 +231,16 @@ module ActiveRecord
def after_rollback(*args, &block)
set_options_for_callbacks!(args)
set_callback(:rollback, :after, *args, &block)
- unless ActiveRecord::Base.raise_in_transactional_callbacks
- ActiveSupport::Deprecation.warn(CALLBACK_WARN_MESSAGE)
- end
+ end
+
+ def raise_in_transactional_callbacks
+ ActiveSupport::Deprecation.warn('ActiveRecord::Base.raise_in_transactional_callbacks is deprecated and will be removed without replacement.')
+ true
+ end
+
+ def raise_in_transactional_callbacks=(value)
+ ActiveSupport::Deprecation.warn('ActiveRecord::Base.raise_in_transactional_callbacks= is deprecated, has no effect and will be removed without replacement.')
+ value
end
private