This project is archived and is in readonly mode.
ActiveSupport::Callbacks :rescuable => true does not work for errors in :before callbacks [Patch]
-
hjdivad
- Tag changed from callbacks active_support to active_support, callbacks
-
hjdivad
- Tag changed from active_support, callbacks to activesupport, callbacks
-
hjdivad
- Title changed from ActiveSupport::Callbacks :rescuable => true does not work for errs in :before callbacks [Patch] to ActiveSupport::Callbacks :rescuable => true does not work for errors in :before callbacks [Patch]
-
Michael Koziarski
- Assigned user set to Yehuda Katz (wycats)
- Importance changed from to Low
-
hjdivad
- Tag changed from activesupport, callbacks to activesupport, callbacks, patch
I have uploaded a better patch than the original, and also updated the git
branch. My original patch broke callbacks with :before and :around with
:rescuable => true.Also, quite apart from running :after callbacks when :before callbacks raised
exceptions, it seems there was a general problem with the :rescuable feature
with :around callbacks that resulted fromrescued_errorbeing first declared
in a block, and thus undefined at the conditional raise.def compile(key=nil, object=nil) method = [] method << "value = nil" method << "halted = false" # The :around callback start will result in a method invocation and the # beginning of a block... each do |callback| method << callback.start(key, object) end # This causes rescued_error to be local to that block... if config[:rescuable] method << "rescued_error = nil" method << "begin" end method << "value = yield if block_given? && !halted" if config[:rescuable] method << "rescue Exception => e" method << "rescued_error = e" method << "end" end reverse_each do |callback| method << callback.end(key, object) end # and thus undefined at this line method << "raise rescued_error if rescued_error" if config[:rescuable] method << "halted ? false : (block_given? ? value : true)" method.compact.join("\n") end -
Santiago Pastorino
- State changed from new to open
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino
- State changed from open to stale
