Add option to stop swallowing errors on callbacks.#16537
Add option to stop swallowing errors on callbacks.#16537chancancode merged 1 commit intorails:masterfrom
Conversation
There was a problem hiding this comment.
this code didnt change, just had to move it, so I can have access to clear_transaction_record_state force_clear_transaction_record_state restore_transaction_record_state
|
@chancancode I guess I addressed all your concerns:
|
There was a problem hiding this comment.
I'll start with describing the behavior (i.e. errors are only logged) and the future change. The "option" is really just an opt-in flag and should be mentioned last. (Same for the changelog entry)
But we can also improve this after merging.
Currently, Active Record will rescue any errors raised within
after_rollback/after_create callbacks and print them to the
logs. Next versions of rails will not rescue those errors anymore,
and just bubble them up, as the other callbacks.
This adds a opt-in flag to enable that behaviour, of not rescuing
the errors.
Example:
# For not swallow errors in after_commit/after_rollback
config.active_record.errors_in_transactional_callbacks = true
[fixes rails#13460]
|
@chancancode Warning message, CHANGELOG, and commit message updated. |
Add option to stop swallowing errors on callbacks.
There was a problem hiding this comment.
Is ite an acronym for something?
|
Perhaps new apps should be generated with the config option already set? |
|
@jonleighton yep, it's been added in c7c2df2 (Thanks for taking your time to help review this by the way!) |
See [#14488] [1] and [#16537] [2] for more details. [1]: [rails/rails#14488] [2]: [rails/rails#16537]
See [#14488] and [#16537] for more details. [#14488]: [rails/rails#14488] [#16537]: [rails/rails#16537]
See [#14488] and [#16537] for more details. [#14488]: [rails/rails#14488] [#16537]: [rails/rails#16537]
Seconds take of #14488 .
After the transaction refactor, we can cleanly apply this patch, as we have a better control of the stack of transactions, and we know that even when raising errors, the transaction wont leaky into the stack.
Description
Add option to stop swallowing standard errors on
after_commitandafter_rollback.Currently the option will be +false+ and throw a warning untill set it to +true+.
Example:
The option should be removed in future versions of Rails, as the desired
behaviour is not to swallow exceptions.
[fixes #13460]
review @jonleighton @rafaelfranca @tenderlove @chancancode @senny